1 
2 #ifndef WEBSOCKCALLBACKS_H_INCLUDED
3 #define WEBSOCKCALLBACKS_H_INCLUDED
4 
5 #include "civetweb.h"
6 
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10 
11 typedef struct tWebSockInfo {
12 	int webSockState;
13 	unsigned long initId;
14 	struct mg_connection *conn;
15 } tWebSockInfo;
16 
17 #define MAX_NUM_OF_WEBSOCKS (256)
18 typedef struct tWebSockContext {
19 	int runLoop;
20 	void *thread_id;
21 	tWebSockInfo *socketList[MAX_NUM_OF_WEBSOCKS];
22 } tWebSockContext;
23 
24 
25 void websock_init_lib(const struct mg_context *ctx);
26 void websock_exit_lib(const struct mg_context *ctx);
27 
28 void
29 websock_send_broadcast(struct mg_context *ctx, const char *data, int data_len);
30 
31 void websocket_ready_handler(struct mg_connection *conn, void *_ignored);
32 int websocket_data_handler(struct mg_connection *conn,
33                            int flags,
34                            char *data,
35                            size_t data_len,
36                            void *_ignored);
37 void connection_close_handler(const struct mg_connection *conn, void *_ignored);
38 
39 
40 #ifdef __cplusplus
41 }
42 #endif
43 
44 #endif