WebsocketConnection.h
Go to the documentation of this file.
43 using WebsocketBinaryDelegate = Delegate<void(WebsocketConnection&, uint8_t* data, size_t size)>;
112 static void broadcast(const char* message, size_t length, ws_frame_type_t type = WS_FRAME_TEXT);
300 size_t encodeFrame(ws_frame_type_t type, const char* inData, size_t inLength, char* outData, size_t outLength,
WsFrameInfo()=default
HttpConnection * getConnection()
Gets the underlying HTTP connection.
Definition: WebsocketConnection.h:249
void setUserData(void *userData)
Attaches a user data to a websocket connection.
Definition: WebsocketConnection.h:157
Definition: WebsocketConnection.h:64
WsFrameInfo(ws_frame_type_t type, char *payload, size_t payloadLength)
Definition: WebsocketConnection.h:58
const char * c_str() const
Get a constant (un-modifiable) pointer to String content.
Definition: WString.h:641
void send(const String &message, ws_frame_type_t type=WS_FRAME_TEXT)
Sends websocket message from a String.
Definition: WebsocketConnection.h:101
void sendString(const String &message)
Sends a string websocket message.
Definition: WebsocketConnection.h:128
bool operator==(const WebsocketConnection &rhs) const
Test if another connection refers to the same object.
Definition: WebsocketConnection.h:175
static void broadcast(const String &message, ws_frame_type_t type=WS_FRAME_TEXT)
Broadcasts a message to all active websocket connections.
Definition: WebsocketConnection.h:119
Definition: WebsocketConnection.h:51
Definition: TcpClient.h:46
#define DECLARE_FSTR(name)
Declare a global FSTR::String& reference.
Definition: String.hpp:63
void sendBinary(const uint8_t *data, size_t length)
Sends a binary websocket message.
Definition: WebsocketConnection.h:138
void setBinaryHandler(WebsocketBinaryDelegate handler)
Sets the callback handler to be called after a binary websocket message is received.
Definition: WebsocketConnection.h:212
size_t length(void) const
Obtain the String length in characters, excluding NUL terminator.
Definition: WString.h:237
WsConnectionState getState()
Gets the state of the websocket connection.
Definition: WebsocketConnection.h:268
void setConnectionHandler(WebsocketDelegate handler)
Sets the callback handler to be called after successful websocket connection.
Definition: WebsocketConnection.h:194
void setDisconnectionHandler(WebsocketDelegate handler)
Sets the callback handler to be called before closing a websocket connection.
Definition: WebsocketConnection.h:228
Definition: WebsocketConnection.h:47
Provides http base used for client and server connections.
Definition: HttpConnection.h:27
void setPongHandler(WebsocketDelegate handler)
Sets the callback handler to be called when pong reply received.
Definition: WebsocketConnection.h:220
Definition: WebsocketConnection.h:46
void setConnection(HttpConnection *connection, bool isClientConnection=true)
Sets the underlying (transport ) HTTP connection.
Definition: WebsocketConnection.h:259
static const WebsocketList & getActiveWebsockets()
Obtain the list of active websockets.
Definition: WebsocketConnection.h:185
void * getUserData()
Retrieves user data attached.
Definition: WebsocketConnection.h:166
Represents either an incoming or outgoing response to a HTTP request.
Definition: HttpResponse.h:25
void setMessageHandler(WebsocketMessageDelegate handler)
Sets the callback handler to be called after a websocket message is received.
Definition: WebsocketConnection.h:203
Definition: WebsocketConnection.h:48
virtual ~WebsocketConnection()
Definition: WebsocketConnection.h:74