web_websocket_close
Closes a WebSocket connection.
C Language
int web_websocket_close("ID=connection ID", ["Code=<4_digit_ code>",] [ "Reason=<reason for closure>",] LAST);| Miscellaneous Functions |
| ID | The ID of the connection to close. |
| Code | The WebSocket connection close code. This can be an integer ranging from 1000 to 1011. |
| Reason | A string indicating the reason of the closure. |
| LAST | Required marker for the end of the argument list. |
web_websocket_close closes the WebSocket connection to the server with the specified ID. For a list of the callback functions, see WebSocket Callback Functions.
Return Values
This function returns LR_PASS (0) on success, and LR_FAIL (1) on failure.
Parameterization
Standard Parameterization is supported for all of this function's arguments.
Example
In the following example, the Vuser creates a WebSocket, sends a message, and then closes it.
#include "as_web.h"
Action()
{
web_websocket_connect("ID=0", "URI=ws://pumpkin:9876/", "Origin=http://pumpkin:9876", "OnOpenCB=OnOpenCB0", "OnMessageCB=OnMessageCB0", "OnErrorCB=OnErrorCB0", "OnCloseCB=OnCloseCB0", LAST);
web_websocket_send("ID=0", "Buffer=sample text message", "IsBinary=0", LAST);
web_websocket_send("ID=0", "Buffer/File={myfile}", "IsBinary=0", LAST);
/*Connection ID 0 received buffer WebSocketReceive0*/
lr_think_time(7);
web_websocket_close("ID=0", "Code=1000", "Reason=OK", LAST);
return 0;
}

