diff -r 638e7dd1d560 -r 4b54d6f79d25 bmsd/websocket.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bmsd/websocket.h Mon May 11 17:32:08 2020 +0200 @@ -0,0 +1,31 @@ +/** + * @file websocket.h + */ + +#ifndef _WEBSOCKET_H +#define _WEBSOCKET_H + + +struct per_session_data__lws_mirror { + struct lws *wsi; + int ringbuffer_tail; +}; + +/** + * @brief Broadcast messages to all connected websocket clients. + * @param msg The message to send. Messages are placed in a ringbuffer queue. + */ +void ws_broadcast(char *msg); + +/** + * @brief Check if a connection is idle for 45 seconds and if so send a ping like + * message to keep the connection alive. Call this function at regular intervals. + */ +void ws_check(void); + +/** + * @brief The websockets server thread. + */ +void *ws_loop(void *); + +#endif