WE310F5  39.00.000
m2mb_websocket.h
Go to the documentation of this file.
1 /*===============================================================================================*/
2 /* >>> Copyright (C) Telit Communications S.p.A. Italy All Rights Reserved. <<< */
30 /* Global declarations ==========================================================================*/
31 #ifndef M2MB_WEBSOCKET_H
32 #define M2MB_WEBSOCKET_H
33 
48 /*-----------------------------------------------------------------------------------------------*/
49 
50 #define WEBSOCKETC_MAX_CLIENTS (4)
52 #define WEBSOCKET_MAX_SUBPROTOCOLS (4)
54 /* Global typedefs ==============================================================================*/
55 
58 typedef enum {
65 
69 typedef enum {
81 
85 typedef enum {
89 
93 typedef enum {
99 
103 typedef enum {
116 
121 
125  typedef struct M2MB_WEBSOCKET_CTX{
129 
135 {
139  const UINT8 *data;
157  const char *subprotocol;
161 
165 typedef void (* M2MB_WEBSOCKETC_EVENT_CB_T)(
169  void * arg,
175  M2MB_WEBSOCKET_EVENT_INFO_T *event_Info
177  );
188 {
189  const char *origin;
216 typedef enum
217 {
222 
227 {
229  struct {
230  char *hdr1, *hdr2;
231  }httpheaders;
233 /* Global variables =============================================================================*/
234 
235 /* Global functions =============================================================================*/
236 /*-----------------------------------------------------------------------------------------------*/
285 
286 
287 /*-----------------------------------------------------------------------------------------------*/
337 /*-----------------------------------------------------------------------------------------------*/
391  INT8 *p_server, UINT16 port, char *pResource_path ) ;
392 
393 /*-----------------------------------------------------------------------------------------------*/
449 /*-----------------------------------------------------------------------------------------------*/
523 int m2mb_websocket_send(M2MB_WEBSOCKET_CTX_T *pCtx, char *pMsg, UINT32 msglen,
524  M2MB_WEBSOCKET_DATA_TYPE_E datatype, UINT8 end_of_message) ;
525 /*-----------------------------------------------------------------------------------------------*/
595  UINT32 ping_data_length) ;
596 /*-----------------------------------------------------------------------------------------------*/
661  UINT32 pong_data_length);
662 /*-----------------------------------------------------------------------------------------------*/
722  M2MB_WEBSOCKET_OPTION_E opt, void *opt_Value, UINT32 *opt_Length);
723 
725 #endif /* M2MB_WEBSOCKET_H */
Client configuration parameters. For use with m2mb_websocket_cfg.
M2MB_STATUS_T m2mb_websocket_pong(M2MB_WEBSOCKET_CTX_T *pCtx, char *pPong_data, UINT32 pong_data_length)
Send a websocket pong.
M2MB_WEBSOCKETC_EVENT_CB_T * pUsercb
unsigned char UINT8
Definition: m2mb_types.h:86
M2MB_WEBSOCKET_OPTION_E
Websocket options that can be read using m2mb_websocketc_get_opt API.
M2MB_WEBSOCKET_CLOSE_STATUS_E close_Status_Code
union M2MB_WEBSOCKET_CONF_PARAMS M2MB_WEBSOCKET_CFG_PARAMS_T
Client configuration parameters. For use with m2mb_websocket_cfg.
struct M2MB_WEBSOCKET_CTX M2MB_WEBSOCKET_CTX_T
websocket client context used with every websocket API.
INT32 M2MB_STATUS_T
Definition: m2mb_status.h:97
M2MB_STATUS_T m2mb_websocket_ping(M2MB_WEBSOCKET_CTX_T *pCtx, char *pPing_data, UINT32 ping_data_length)
Send a websocket ping.
M2MB_SSL_CTXT_HANDLE sslhandle
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 ...
unsigned short UINT16
Definition: m2mb_types.h:87
M2MB_STATUS_T m2mb_websocket_connect(M2MB_WEBSOCKET_CTX_T *pCtx, INT8 *p_server, UINT16 port, char *pResource_path)
Establishes a websocket connection.
M2MB_STATUS_T m2mb_websocket_open(M2MB_WEBSOCKET_CTX_T **pCtx, M2MB_WEBSOCKET_OPEN_PARAMS_T *pParams)
Create a client websocket context.
UINT8 BOOLEAN
Definition: m2mb_types.h:95
M2MB_WEBSOCKET_CONF_ID_E
Client configuration parameters. For use with m2mb_websocketc_new.
M2MB_WEBSOCKET_DATA_TYPE_E data_Type
websocket client context used with every websocket API.
signed char INT8
Definition: m2mb_types.h:80
M2MB_WEBSOCKET_EVENT_E
Websocket event type. Provided to M2MB_Event_CB_t callback.
M2MB_STATUS_T m2mb_websocket_close(M2MB_WEBSOCKET_CTX_T *pCtx)
Closes the websocket connection.
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.
UINT32 M2MB_SSL_OBJ_HDL_T
UINT32 M2MB_WEBSOCKET_HANDLE_T
Handle to websocket context.
struct M2MB_WEBSOCKET_CONF_PARAMS::@6 httpheaders
unsigned long int UINT32
Definition: m2mb_types.h:88
M2MB_WEBSOCKET_HANDLE_T handle
Client configuration parameters. For use with m2mb_websocketc_new.
HANDLE M2MB_SSL_CTXT_HANDLE
SSL context handle. This is obtained from m2mb_ssl_open API and then used in subsequent SSL APIs...
Definition: m2mb_ssl.h:165
M2MB_WEBSOCKET_CLOSE_STATUS_E
Connection close status.
M2MB_WEBSOCKET_DATA_TYPE_E
Type of data sent or received on websocket.
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.
Websocket event. Received by M2MB_WEBSOCKETC_EVENT_CB_T callback registered with m2mb_websocketc_new ...
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.
M2MB_WEBSOCKET_STATE_E
The state of the websocket.
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.
struct M2MB_WEBSOCKET_OPEN_PARAMS M2MB_WEBSOCKET_OPEN_PARAMS_T
Client configuration parameters. For use with m2mb_websocketc_new.