WebSockCallbacks.h 1.0 KB

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