DebugHandler::AbstractWebSocketDebugHandler Class Referenceabstract

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

Inheritance diagram for DebugHandler::AbstractWebSocketDebugHandler:
[legend]

## Public Member Functions

| 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

Encode data and broadcast data using WebSocketHandler::sendAll() a message to all connected clients. Intercept 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 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. Intercept 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

Encode data and send using WebSocketHandler::sendOne() a message to single connection given its connection ID. Intercept method when implementing a 3rd party protocol.