Sends a text message to the WebSocket server. The function does not wait for a response. Note: A WebSocket is an asynchronous communication channel, which is not bound to the conventional request-response pattern. Both the client and the server can send messages at any time.
webapi.bdh
WebSocketSendTextMessage( in hWebSocket : number, in sData : dstring, in nMaxFragmentSize : number optional ): boolean
Parameter | Description |
---|---|
hWebSocket | A handle, which identifies the WebSocket. To retrieve this handle, use the WebSocketConnect() function. |
sData | The content of the message to be sent to the server. |
nMaxFragmentSize | Large messages can be split up into smaller parts or fragments by the client. This parameter specifies the maximum size of one fragment. |
true if successful
false otherwise
transaction TMain var hWebSocket : number; begin hWebSocket := WebSocketConnect("http://echo.websocket.org", callback(FWebSocketMessageReceived)); WebSocketSendTextMessage(hWebSocket, "Rock it with HTML5 WebSocket"); Print("Waiting..."); Wait(4.1); WebSocketSendTextMessage(hWebSocket, "Hello World!"); Print("Waiting..."); Wait(3.6); WebSocketSendTextMessage(hWebSocket, "Bye"); WebSocketClose(hWebSocket); end TMain;