XROAD
websocket.h
Go to the documentation of this file.
1 
6 #pragma once
7 #include <string.h>
8 #include <common/xroad_string.h>
9 #include <common/xroad_xml.h>
10 
11 #ifdef __cplusplus
12 extern "C"
13 {
14 #endif
15 
16 typedef struct websocket_s websocket_t;
17 
18 typedef enum
19 {
20  ws_data_type_text = 0,
21  ws_data_type_binary = 1
22 } ws_data_type_t;
23 
24 typedef struct
25 {
26  void* ctx;
30  void (*on_connected)(websocket_t*, void*);
37  void (*on_disconnected)(websocket_t*, bool, void*);
46  void (*on_data)(websocket_t*, const void*, size_t, ws_data_type_t, void*);
47 
51  void (*on_data_start)(websocket_t*, const size_t, void*);
55  void (*on_data_finish)(websocket_t*, void*);
56 
58 
66 websocket_t* websocket_create(xroad_xml_tag_t cfg, xroad_str_t address, websocket_callback_t cback);
67 
72 void websocket_destroy(websocket_t* ws);
73 
79 xroad_errno_t websocket_start(websocket_t* ws);
80 
86 xroad_errno_t websocket_stop(websocket_t* ws);
87 
95 xroad_errno_t websocket_send(websocket_t* ws, void* data, size_t len, ws_data_type_t ws_wp);
96 
97 #ifdef __cplusplus
98 }
99 #endif
Definition: websocket.h:25
Definition: xroad_string.h:29
xroad_errno_t websocket_start(websocket_t *ws)
xroad_errno_t websocket_stop(websocket_t *ws)
xroad_errno_t websocket_send(websocket_t *ws, void *data, size_t len, ws_data_type_t ws_wp)
websocket_t * websocket_create(xroad_xml_tag_t cfg, xroad_str_t address, websocket_callback_t cback)
void websocket_destroy(websocket_t *ws)