mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-28 12:30:58 +00:00
Update examples to NOT use mg_*mprintf
This commit is contained in:
1 parent
f122bd5797
commit
189aa80743
3 files changed
+11
-17
No files matched your search
@@ -56,14 +56,12 @@ static void fn(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
|
||||
|
||||
static void timer_fn(void *arg) {
|
||||
struct mg_mgr *mgr = (struct mg_mgr *) arg;
|
||||
char *msg = mg_mprintf("{%Q:%Q,%Q:[%d,%d,%d]}", "method", "notification1",
|
||||
"params", 1, 2, 3);
|
||||
// Broadcast message to all connected websocket clients.
|
||||
for (struct mg_connection *c = mgr->conns; c != NULL; c = c->next) {
|
||||
// Send JSON-RPC notifications to marked connections
|
||||
if (c->label[0] == 'W') mg_ws_send(c, msg, strlen(msg), WEBSOCKET_OP_TEXT);
|
||||
if (c->label[0] != 'W') continue;
|
||||
mg_ws_printf(c, WEBSOCKET_OP_TEXT, "{%Q:%Q,%Q:[%d,%d,%d]}", "method",
|
||||
"notification1", "params", 1, 2, 3);
|
||||
}
|
||||
free(msg);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
|
||||
Reference in new issue
Block a user