Browse Source

+ f2b_csocket_event_broadcast()

master
Alex 'AdUser' Z 4 years ago
parent
commit
5c77a8f12e
  1. 14
      src/csocket.c
  2. 6
      src/csocket.h

14
src/csocket.c

@ -514,3 +514,17 @@ f2b_csocket_poll(void (*cb)(const f2b_cmd_t *cmd, f2b_buf_t *res)) {
} /* foreach connection(s) */
return;
}
void
f2b_csocket_event_broadcast(const char *evt) {
f2b_conn_t *conn = NULL;
for (int cnum = 0; cnum < CSOCKET_MAX_CLIENTS; cnum++) {
if ((conn = csock.clients[cnum]) == NULL)
continue;
if (conn->flags & CSOCKET_CONN_EVENTS) {
f2b_buf_append(&conn->send, "!", 1);
f2b_buf_append(&conn->send, evt, 0);
f2b_buf_append(&conn->send, "\n", 1);
}
} /* for */
}

6
src/csocket.h

@ -43,4 +43,10 @@ void f2b_csocket_destroy();
*/
void f2b_csocket_poll(void (*cb)(const f2b_cmd_t *cmd, f2b_buf_t *res));
/**
* @brief Send text message to connected clients
* @param msg text
*/
void f2b_csocket_event_broadcast(const char *msg);
#endif /* F2B_CSOCKET_H_ */

Loading…
Cancel
Save