153 const DefaultQueuePollingInterval = 250ms;
207 send(data msg,
int op,
bool fin);
292 const DefaultSocketSendTimeout = 30s;
295 const DefaultHeartbeatInterval = 20s;
298 const DefaultHeartbeatMsg =
"heartbeat";
309 hash<string, WebSocketConnection>
ch;
312 softint heartbeat = DefaultHeartbeatInterval;
315 string heartbeat_msg = DefaultHeartbeatMsg;
321 string tlk = get_random_string(50);
485 static string getDataString(*data d);
this class represents a connection to a websocket client
Definition: WebSocketHandler.qm.dox.h:143
registered()
Called when the connection has been registered in handler and accept sending messages.
setSocket(Socket sock)
Sets the socket used by the server for the connection.
flush()
Flush all output data.
Qore::Thread::Queue queue()
the Queue object stores messages to be sent to the server
int tid
The TID of the I/O thread.
Definition: WebSocketHandler.qm.dox.h:160
bool stop_flag
Stop connection flag.
Definition: WebSocketHandler.qm.dox.h:150
Socket sock
The socket used by the server for this connection.
Definition: WebSocketHandler.qm.dox.h:166
sendEncoded(binary msg)
Pushes an already-encoded message on the connection's message queue.
gotMessage(binary msg)
This method is called when messages from the client are received.
gotMessage(string msg)
This method is called when messages from the client are received.
constructor(WebSocketHandler handler)
the constructor is called when a new connection is made by a websocket client
int gotRawMessage(hash< WsMsgInfo > msg)
This method is called when a message is received.
*binary pollDataImmediate()
This method is called to poll for messages from the client to send from the server.
connectionClosed()
This method is called when the connection is closed.
send(data msg, int op, bool fin)
Pushes an unencoded message on the connection's message queue.
send(data msg)
Pushes an unencoded message on the connection's message queue.
*binary pollData()
This method is called to poll for messages from the client to send from the server.
stop()
force closing socket related to connection
WebSocketHandler handler
The parent handler object.
Definition: WebSocketHandler.qm.dox.h:147
bool flushIo(WebSocketConnection wsc, Socket sock)
Flushes I/O in the connection queue.
constructor(*HttpServer::AbstractAuthenticator auth, *hash< auto > opts)
create the object optionally with the given AbstractAuthenticator
deregisterConnectionImpl(WebSocketConnection wsc)
called when the connection terminates; the default implementation does nothing
logWarn(string fmt,...)
Log to the logger.
logError(string fmt,...)
Log to the logger.
*list< string > getConnectionIds()
get list of socket connection ids
string getHeartbeatMessage()
returns the heartbeat message as a string
setHeartbeat(softint seconds)
sets the heartbeat interval as a number of seconds
setHeartbeatMessage(string msg)
sets the heartbeat message
RWLock rwl()
connection read-write lock
int getHeartbeat()
returns the connection heartbeat interval as a number of seconds
logDebug(string fmt,...)
Log to the logger.
logInfo(string fmt,...)
Log to the logger.
sendOne(softstring id, data d)
sends a message to the given connection ID
WebSocketConnection getConnectionImpl(hash< auto > cx, hash< auto > hdr, string cid)
called when a connection is established; the default implementation creates a WebSocketConnection obj...
bool startImpl(softstring lid, hash< auto > cx, hash< auto > hdr, Qore::Socket sock)
called from the HTTP server after the handleRequest() method indicates that a dedicated connection sh...
hash< string, WebSocketConnection > ch
connection hash
Definition: WebSocketHandler.qm.dox.h:309
WebSocketConnection doNewConnection(hash< auto > cx, hash< auto > hdr, string cid)
called when a connection is established; registers the new connection internally
sendAll(data d)
sends a message to all connected clients
hash< auto > handleRequest(hash< auto > cx, hash< auto > hdr, *data b)
called by the HTTP server to handle incoming HTTP requests
stopOne(softstring id)
stop given connection ID
const WSC_Break
If the server should stop listening (message already processed)
Definition: WebSocketHandler.qm.dox.h:126
const WSC_Continue
If the server should continue listening (message already processed)
Definition: WebSocketHandler.qm.dox.h:123
const WSC_Process
Definition: WebSocketHandler.qm.dox.h:120
the WebSocketHandler namespace contains all the objects in the WebSocketHandler module
Definition: WebSocketHandler.qm.dox.h:115