Qore DebugHandler Module Reference 0.1
Loading...
Searching...
No Matches
DebugHandler::AbstractWebSocketDebugHandler Class Referenceabstract

The abstract web socket debug handler class. More...

#include <DebugHandler.qm.dox.h>

Inheritance diagram for DebugHandler::AbstractWebSocketDebugHandler:
[legend]

Public Member Methods

 broadcastData (auto data)
 sends data to all connections More...
 
abstract string encodeData (auto data)
 encode websocket data
 
WebSocketHandler::WebSocketConnection getConnectionImpl (hash cx, hash hdr, string cid)
 called when a connection is established; the default implementation creates a WebSocketConnection object
 
abstract *string getContentType ()
 returns the MIME type for serialized data
 
hash handleRequest (hash cx, hash hdr, *data b)
 called by the HTTP server to handle incoming HTTP requests More...
 
abstract receiveData (hash cx, string msg)
 called when web socket receives data More...
 
 sendData (hash cx, auto data)
 sends data to the given connection More...
 

Detailed Description

The abstract web socket debug handler class.

Connections are represented by an object descended from WebSocketConnection which is instantiated via WebSocketHandler::WebSocketHandler::getConnectionImpl().

The handler is registered via HttpServer::setHandler() to receive messages.

Receiving WebSocket Messages from Clients
When a message is received via WebSocketConnection::gotMessage() from the client then it is passed to receiveData as is.
Sending WebSocket Message to Clients
To send a message to a websocket client, call one of the following methods sendData or broadcastData

Websocket connections are identified by their HTTP connection ID as passed in WebSocketHandler::handleRequest() in the "cx.id" argument when the connection is first established.

Member Function Documentation

◆ broadcastData()

DebugHandler::AbstractWebSocketDebugHandler::broadcastData ( auto  data)

sends data to all connections

Encodes broadcasts data using WebSocketHandler::sendAll() to send a message to all connected clients

Override this method when implementing a 3rd party protocol

◆ handleRequest()

hash DebugHandler::AbstractWebSocketDebugHandler::handleRequest ( hash  cx,
hash  hdr,
*data  b 
)

called by the HTTP server to handle incoming HTTP requests

It adds custom header X-QoreDebugWsProtocol to the response

◆ receiveData()

abstract DebugHandler::AbstractWebSocketDebugHandler::receiveData ( hash  cx,
string  msg 
)
pure virtual

called when web socket receives data

Data are passed as is, i.e. decoding is needed

Override this method when implementing a 3rd party protocol

Implemented in DebugHandler::WebSocketDebugHandler.

◆ sendData()

DebugHandler::AbstractWebSocketDebugHandler::sendData ( hash  cx,
auto  data 
)

sends data to the given connection

Encodes data and sends using WebSocketHandler::sendOne() to send a message to a single connection given its connection ID

Override this method when implementing a 3rd party protocol