raccoon::web::WebSocketConnection class
#include <ws.hpp>

A websocket connection.

It is UNDEFINED BEHAVIOR to call any instance methods until conn->ready() returns true.

Base classes

class Connection

Public types

using callback = std::function<void(WebSocketConnection*, const std::vector<uint8_t>&)>

Constructors, destructors, conversion operators

WebSocketConnection(const WebSocketConnection&) deleted
WebSocketConnection(WebSocketConnection&&) defaulted
~WebSocketConnection() override

Public functions

auto operator=(const WebSocketConnection&) -> WebSocketConnection& deleted
auto operator=(WebSocketConnection&&) -> WebSocketConnection& defaulted
void close() override
void close(WebSocketCloseStatus status)
auto close(WebSocketCloseStatus status, std::vector<uint8_t> data) -> size_t
auto send(std::vector<uint8_t> data, unsigned flags = CURLWS_TEXT) -> size_t
auto file() const -> FILE* override noexcept

Private functions

void start_() override

Typedef documentation

using raccoon::web::WebSocketConnection::callback = std::function<void(WebSocketConnection*, const std::vector<uint8_t>&)>

A websocket callback function.

Parameters are this class, data buffer, and data length.

Function documentation

raccoon::web::WebSocketConnection::~WebSocketConnection() override

Close this websocket connection.

void raccoon::web::WebSocketConnection::close() override

Close this websocket connection.

void raccoon::web::WebSocketConnection::close(WebSocketCloseStatus status)

Close this websocket connection with reason.

size_t raccoon::web::WebSocketConnection::close(WebSocketCloseStatus status, std::vector<uint8_t> data)

Close this websocket connection with reason and data.

Returns amount of data written.

size_t raccoon::web::WebSocketConnection::send(std::vector<uint8_t> data, unsigned flags = CURLWS_TEXT)

Send data to the websocket.

Returns the number of bytes sent.

FILE* raccoon::web::WebSocketConnection::file() const override noexcept

Dummy, websockets don't download to files.

void raccoon::web::WebSocketConnection::start_() override private

Start this websocket connection.