web_websocket_connect
Creates a WebSocket connection.
C Language
int web_websocket_connect("ID=connection", "URI=ws://server:port", ["Origin=value ", SecWebSocketKey=value ", "SecWebSocketProtocol=value ", SecWebSocketExtensions=value, OnOpenCB=func_name, OnMessageCB=func_name, OnErrorCB=func_name, OnCloseCB=func_name, ] LAST);
Example: web_websocket_connect, web_websocket_close, web_websocket_send | Miscellaneous Functions |
ID | A unique number indicating the connection number. This value is generated automatically during code generation. |
URI | The WebSocket endpoint in ws:// or wss:// (secure WebSocket schema) format. |
Origin | Origin header value. Optional: Only generated if detected during the recording session. |
SecWebSocketKey | Sec-WebSocket-Key header value. Optional: The WebSocket key value. Not recorded, but can be added manually. |
SecWebSocketProtocol | Sec-WebSocket-Protocol header value. Optional: Only generated if detected during the recording session. |
SecWebSocketExtensions | Sec-WebSocket-Extensions header value. Optional: Only generated if detected during the recording session. |
OnOpenCB | Callback function name for an OnOpen event (optional). For details, see WebSocket Callback Functions. |
OnMessageCB | Callback function name for an OnMessage event (optional). For details, see WebSocket Callback Functions. |
OnErrorCB | Callback function name for an OnError event (optional). For details, see WebSocket Callback Functions. |
OnCloseCB | Callback function name for an OnClose event (optional). For details, see WebSocket Callback Functions. |
LAST | Required marker for the end of the argument list. |
This function creates a WebSocket connection upon which to send the message.
Headers that were detected during recording will be generated automatically, except for SecWebSocketKey. To add additional headers to the handshake request, place web_add_header or web_add_cookie steps before this function.
Callbacks will be generated with the default implementation commented out. For a description 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.