Class WebSocketHandler() Professional
Class function of the WebSocketHandler class.
WebsocketHandler is an abstract class which must be used to implement the handlers for websocket endpoints. To do this, a user-defined handler class derived from the class WebSocketHandler must be implemented that overloads the abstract methods :onText(), :onBinary(), :onConnect() and :onDisconnect().
On incoming websocket connections via the class HttpEndpoint an object of the user-defined handler class is instantiated to service the requests from the client. For this the methods :sendText() and :sendBinary() can be used to send messages to the connected client.
The class WebSocketHandler implements the websocket protocol according RFC 6455. If a HTML browser shall be used to establish a connection with the websocket endpoint then the browser must support the websocket protocol according this standard. The following table provides an overview about HTML browsers supporting websockets according RFC 6455:
|Web browser||Minimum version|
|Chrome (PC, Mobile)||16|
|Safari (Mac, iOS)||6|
|Opera (PC, Mobile)||12.10|
An Xbase++ application can utilize the class WebSocketClient() to implement the client site suitable to connect to a websocket server.
The example below demonstrates the implementation of the server side of a websocket connection. Refer to the example of WebSocketClient() to see the implementation of the client side.
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.