libnavajo
web server for static and dynamic pages developement in C++
Public Member Functions | List of all members
WebSocket Class Reference

Public Member Functions

 WebSocket (bool compression=true)
 
virtual bool onOpening (HttpRequest *request)
 
virtual void onClosing (WebSocketClient *client)
 
virtual void onTextMessage (WebSocketClient *client, const std::string &message, const bool fin)
 
virtual void onBinaryMessage (WebSocketClient *client, const unsigned char *message, size_t len, const bool fin)
 
virtual void onPongCtrlFrame (WebSocketClient *client, const unsigned char *message, size_t len)
 
virtual bool onPingCtrlFrame (WebSocketClient *client, const unsigned char *message, size_t len)
 
virtual bool onCloseCtrlFrame (WebSocketClient *client, const unsigned char *message, size_t len)
 
void sendBroadcastTextMessage (const std::string &message, bool fin=true)
 
void sendBroadcastBinaryMessage (const unsigned char *message, size_t length, bool fin=true)
 
void sendBroadcastCloseCtrlFrame (const unsigned char *message, size_t length)
 
void sendBroadcastCloseCtrlFrame (const std::string &reasonMsg="")
 
void sendBroadcastPingCtrlFrame (const unsigned char *message, size_t length)
 
void sendBroadcastPingCtrlFrame (const std::string &message)
 
void sendBroadcastPongCtrlFrame (const unsigned char *message, size_t length)
 
void sendBroadcastPongCtrlFrame (const std::string &message)
 
void newConnectionRequest (HttpRequest *request)
 
void removeAllClients ()
 
void removeClient (WebSocketClient *client, bool cs=false)
 
void removeClient (HttpRequest *request)
 
bool isUsingCompression ()
 
void setUseCompression (bool compression)
 
bool isUsingNaggleAlgo ()
 
void setUseNaggleAlgo (bool naggle)
 
unsigned short getClientSendingMaxLatency ()
 
void setClientSendingMaxLatency (unsigned short ms)
 

Member Function Documentation

unsigned short WebSocket::getClientSendingMaxLatency ( )
inline

Get the maximum latency allowed to send data

Returns
the latency in milliseconds
bool WebSocket::isUsingCompression ( )
inline

Get the compression behavior: data compression allowed or not

Returns
true if compression is allowed
void WebSocket::newConnectionRequest ( HttpRequest request)
inline

New Websocket Connection Request create a new websocket client if onOpening() return true

Parameters
requestthe http request object
virtual void WebSocket::onBinaryMessage ( WebSocketClient client,
const unsigned char *  message,
size_t  len,
const bool  fin 
)
inlinevirtual

Callback on new binary message

Parameters
requestthe http request object
messagethe binary message
lenthe message length
finis the current message finished ?
virtual bool WebSocket::onCloseCtrlFrame ( WebSocketClient client,
const unsigned char *  message,
size_t  len 
)
inlinevirtual

Callback on client close notification

Parameters
requestthe http request object
Returns
true to send an automatic close reply message
virtual void WebSocket::onClosing ( WebSocketClient client)
inlinevirtual

Callback before closing websocket client connection

Parameters
requestthe http request object
virtual bool WebSocket::onOpening ( HttpRequest request)
inlinevirtual

Callback on new websocket client connection

Parameters
requestthe http request object
virtual bool WebSocket::onPingCtrlFrame ( WebSocketClient client,
const unsigned char *  message,
size_t  len 
)
inlinevirtual

Callback on new ping message (should came after a ping message)

Parameters
requestthe http request object
messagethe message
lenthe message length
Returns
true to send an automatic pong reply message
virtual void WebSocket::onPongCtrlFrame ( WebSocketClient client,
const unsigned char *  message,
size_t  len 
)
inlinevirtual

Callback on new pong message (should came after a ping message)

Parameters
requestthe http request object
messagethe message
lenthe message length
virtual void WebSocket::onTextMessage ( WebSocketClient client,
const std::string &  message,
const bool  fin 
)
inlinevirtual

Callback on new text message

Parameters
requestthe http request object
messagethe message
finis the current message finished ?
void WebSocket::removeAllClients ( )
inline

Remove and close all Websocket client's Connection

void WebSocket::removeClient ( WebSocketClient client,
bool  cs = false 
)
inline

Remove and close a given Websocket client

Parameters
clientthe websocket client
csare we inside the critical section ?
void WebSocket::removeClient ( HttpRequest request)
inline

Remove and close a given Websocket client

Parameters
requestthe related http request object
void WebSocket::sendBroadcastBinaryMessage ( const unsigned char *  message,
size_t  length,
bool  fin = true 
)
inline

Send Binary Message to all connected clients

Parameters
messagethe message content
lengththe message length
finis-it the final fragment of the message ?
void WebSocket::sendBroadcastCloseCtrlFrame ( const unsigned char *  message,
size_t  length 
)
inline

Send Close Message Notification to all connected clients

Parameters
reasonMsgthe message content
lengththe message length
void WebSocket::sendBroadcastCloseCtrlFrame ( const std::string &  reasonMsg = "")
inline

Send Close Message Notification to all connected clients

Parameters
reasonMsgthe message content
void WebSocket::sendBroadcastPingCtrlFrame ( const unsigned char *  message,
size_t  length 
)
inline

Send Ping Message Notification to all connected clients

Parameters
messagethe message content
lengththe message length
void WebSocket::sendBroadcastPingCtrlFrame ( const std::string &  message)
inline

Send Ping Message Notification to all connected clients

Parameters
messagethe message content
void WebSocket::sendBroadcastPongCtrlFrame ( const unsigned char *  message,
size_t  length 
)
inline

Send Pong Message Notification to all connected clients

Parameters
messagethe message content
lengththe message length
void WebSocket::sendBroadcastPongCtrlFrame ( const std::string &  message)
inline

Send Pong Message Notification to all connected clients

Parameters
messagethe message content
void WebSocket::sendBroadcastTextMessage ( const std::string &  message,
bool  fin = true 
)
inline

Send Text Message to all connected clients

Parameters
messagethe message content
finis-it the final fragment of the message ?
void WebSocket::setClientSendingMaxLatency ( unsigned short  ms)
inline

Set the maximum latency allowed to the clients to send data

Parameters
msthe latency in milliseconds
void WebSocket::setUseCompression ( bool  compression)
inline

Set if client should compress data (if it's supported by browser) or not

Parameters
compressiontrue to compress

The documentation for this class was generated from the following file: