![]() |
WE310F5
39.00.000
|
This section describes the M2MB APIs to perform websocket client operations. More...
This section describes the M2MB APIs to perform websocket client operations.
#define WEBSOCKET_MAX_SUBPROTOCOLS (4) |
max number of subprotocols supported.
Definition at line 52 of file m2mb_websocket.h.
#define WEBSOCKETC_MAX_CLIENTS (4) |
max number of clients supported.
Definition at line 50 of file m2mb_websocket.h.
typedef UINT32 M2MB_SSL_OBJ_HDL_T |
Handle to an SSL object. This is obtained from a call to qapi_Net_SSL_Obj_New(). The handle is freed with a call to qapi_Net_SSL_Obj_Free().
Definition at line 183 of file m2mb_websocket.h.
typedef union M2MB_WEBSOCKET_CONF_PARAMS M2MB_WEBSOCKET_CFG_PARAMS_T |
Client configuration parameters. For use with m2mb_websocket_cfg.
typedef struct M2MB_WEBSOCKET_CTX M2MB_WEBSOCKET_CTX_T |
websocket client context used with every websocket API.
typedef struct M2MB_WEBSOCKET_EVENT_INFO M2MB_WEBSOCKET_EVENT_INFO_T |
Websocket event. Received by M2MB_WEBSOCKETC_EVENT_CB_T callback registered with m2mb_websocketc_new API.
typedef UINT32 M2MB_WEBSOCKET_HANDLE_T |
Handle to websocket context.
Definition at line 120 of file m2mb_websocket.h.
typedef struct M2MB_WEBSOCKET_OPEN_PARAMS M2MB_WEBSOCKET_OPEN_PARAMS_T |
Client configuration parameters. For use with m2mb_websocketc_new.
typedef void(* M2MB_WEBSOCKETC_EVENT_CB_T) (M2MB_WEBSOCKET_HANDLE_T handle, void *arg, M2MB_WEBSOCKET_EVENT_E event, M2MB_WEBSOCKET_EVENT_INFO_T *event_Info) |
Callback to receive new websocket messages.
Definition at line 165 of file m2mb_websocket.h.
Connection close status.
Definition at line 103 of file m2mb_websocket.h.
Client configuration parameters. For use with m2mb_websocketc_new.
Enumerator | |
---|---|
M2MB_WEBSOCKET_CONF_ECHOMODE | |
M2MB_WEBSOCKET_CONF_HTTPHEADERS_ADD | |
M2MB_WEBSOCKET_CONF_HTTPHEADERS_CLEAR |
Definition at line 216 of file m2mb_websocket.h.
Type of data sent or received on websocket.
Enumerator | |
---|---|
M2MB_WEBSOCKET_DATA_TYPE_TEXT_E | UTF-8 text data. |
M2MB_WEBSOCKET_DATA_TYPE_BINARY_E | Binary data. |
Definition at line 85 of file m2mb_websocket.h.
Websocket event type. Provided to M2MB_Event_CB_t callback.
Definition at line 93 of file m2mb_websocket.h.
Websocket options that can be read using m2mb_websocketc_get_opt API.
Definition at line 69 of file m2mb_websocket.h.
The state of the websocket.
Definition at line 58 of file m2mb_websocket.h.
M2MB_STATUS_T m2mb_websocket_cfg | ( | M2MB_WEBSOCKET_CTX_T * | pCtx, |
M2MB_WEBSOCKET_CONF_ID_E | confid, | ||
M2MB_WEBSOCKET_CFG_PARAMS_T * | cfg | ||
) |
Enables or disables echo mode.
Enables or disables echo mode for particular websocket.
[in] | pClientCtx | Pointer to store websocket client context of type M2MB_WEBSOCKETC_CTX_T. |
[in] | echo_mode | If it is 1, it enables echo mode, otherwise disables it. |
M2MB_STATUS_T m2mb_websocket_close | ( | M2MB_WEBSOCKET_CTX_T * | pCtx | ) |
Closes the websocket connection.
Closes the websocket connection and notify the sender. This also closes the underlying TCP socket and SSL connection.
[in] | pClientCtx | Pointer to store websocket client context of type M2MB_WEBSOCKETC_CTX_T. |
M2MB_STATUS_T m2mb_websocket_connect | ( | M2MB_WEBSOCKET_CTX_T * | pCtx, |
INT8 * | p_server, | ||
UINT16 | port, | ||
char * | pResource_path | ||
) |
Establishes a websocket connection.
Establishes a websocket connection to the server.
[in] | pClientCtx | Pointer to store websocket client context of type M2MB_WEBSOCKETC_CTX_T. |
[in] | p_server | Pointer to the Server hostname or IP address. |
[in] | port | Server port. |
[in] | pResource_path | Server pResource_path. |
M2MB_STATUS_T m2mb_websocket_get_opt | ( | M2MB_WEBSOCKET_CTX_T * | pCtx, |
M2MB_WEBSOCKET_OPTION_E | opt, | ||
void * | opt_Value, | ||
UINT32 * | opt_Length | ||
) |
Get properties of the websocket.
Get properties of the websocket. For example, this can be used to get the negotiated sub-protocol.
[in] | pClientCtx | Pointer to store websocket client context of type M2MB_WEBSOCKETC_CTX_T. |
[in] | opt | Option name to get of type M2MB_WEBSOCKET_OPTION_E. |
[in] | opt_Value | Pointer to copy option value. |
[in] | opt_Length | Pointer to indicate option length. |
M2MB_STATUS_T m2mb_websocket_open | ( | M2MB_WEBSOCKET_CTX_T ** | pCtx, |
M2MB_WEBSOCKET_OPEN_PARAMS_T * | pParams | ||
) |
Create a client websocket context.
Creates a web socket client context.
[in] | pClientCtx | Pointer to store websocket client context of type M2MB_WEBSOCKETC_CTX_T. |
[in] | pConfig | Pointer to the user configuration of type M2MB_WEBSOCKET_CLIENT_CONFIG_T. |
[in] | pUsercb | User call back of type M2MB_WEBSOCKETC_EVENT_CB_T. |
[in] | sslhandle | User SSL handle. |
M2MB_STATUS_T m2mb_websocket_ping | ( | M2MB_WEBSOCKET_CTX_T * | pCtx, |
char * | pPing_data, | ||
UINT32 | ping_data_length | ||
) |
Send a websocket ping.
Send a websocket ping. The resulting pong will be receive by the registered pong callback.
[in] | pClientCtx | Pointer to store websocket client context of type M2MB_WEBSOCKETC_CTX_T. |
[in] | pPing_data | Optional data to include in the ping. |
[in] | ping_data_length | Length of data. |
M2MB_STATUS_T m2mb_websocket_pong | ( | M2MB_WEBSOCKET_CTX_T * | pCtx, |
char * | pPong_data, | ||
UINT32 | pong_data_length | ||
) |
Send a websocket pong.
Send a websocket pong. The application may choose to send a pong unidirectionally without a ping for keep alive.
[in] | pClientCtx | Pointer to store websocket client context of type M2MB_WEBSOCKETC_CTX_T. |
[in] | pPong_data | Optional data to include in the pong. |
[in] | pong_data_length | Length of data. |
int m2mb_websocket_send | ( | M2MB_WEBSOCKET_CTX_T * | pCtx, |
char * | pMsg, | ||
UINT32 | msglen, | ||
M2MB_WEBSOCKET_DATA_TYPE_E | datatype, | ||
UINT8 | end_of_message | ||
) |
Sends application data.
Sends application data.
[in] | pClientCtx | Pointer to store websocket client context of type M2MB_WEBSOCKETC_CTX_T. |
[in] | pMsg | Data Data to send. |
[in] | msglen | Data_Length Length of data. |
[in] | datatype | 1 for text data, and 2 for binary data. |
[in] | end_of_message | end_Of_Message If data contains an entire message, this should be set to 1. Messages can be fragmented. If end_Of_Message is 0, this sends the data as a fragment of a message. The last fragment of the message should be sent with end_Of_Message set to 1. |