WebSockCallbacks.h 892 B

123456789101112131415161718192021222324252627282930313233343536373839
  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 websock_send_broadcast(struct mg_context *ctx, const char * data, int data_len);
  21. void websocket_ready_handler(struct mg_connection *conn);
  22. int websocket_data_handler(struct mg_connection *conn, int flags, char *data, size_t data_len);
  23. void connection_close_handler(const struct mg_connection *conn);
  24. #ifdef __cplusplus
  25. }
  26. #endif
  27. #endif