Closes a WebSocket communication channel. The client sends a close message to the server and waits until the server actually closes the connection. After WebSocketClose has been called, the associated WebSocket handle is not valid any longer.
webapi.bdh
WebSocketClose( in hWebSocket : number, in nStatusCode : number optional, in sCloseMessage : dstring optional ): boolean;
Parameter | Description |
---|---|
hWebSocket | A handle, which identifies the WebSocket. To retrieve this handle, use the WebSocketConnect() function. |
nStatusCode | Optional: Reason for closing the WebSocket connection. For valid values, refer to
http://tools.ietf.org/html/rfc6455#section-7.4. Some well known values are defined as BDL constants:
|
sCloseMessage | Optional: Additional message for diagnostic purposes |
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;