WebSockCallbacks.h 894 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. void * thread_id;
  15. tWebSockInfo *socketList[MAX_NUM_OF_WEBSOCKS];
  16. } tWebSockContext;
  17. void websock_init_lib(struct mg_context *ctx);
  18. void websock_exit_lib(struct mg_context *ctx);
  19. void websock_send_broadcast(struct mg_context *ctx, const char * data, int data_len);
  20. void websocket_ready_handler(struct mg_connection *conn);
  21. int websocket_data_handler(struct mg_connection *conn, int flags, char *data, size_t data_len);
  22. void connection_close_handler(struct mg_connection *conn);
  23. #ifdef __cplusplus
  24. }
  25. #endif
  26. #endif