Rename struct mg_connection::label -> data. Make its size configurable

This commit is contained in:
cpq committed 2023-01-10 08:19:49 +00:00
1 parent 3d75d71767
commit da5e8e9778
27 files changed
+3204 -2247

No files matched your search

+2 -2
View File
@@ -16,7 +16,7 @@ static void fn(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
if (mg_http_match_uri(hm, "/websocket")) {
mg_ws_upgrade(c, hm, NULL); // Upgrade HTTP to Websocket
c->label[0] = 'W'; // Set some unique mark on a connection
c->data[0] = 'W'; // Set some unique mark on a connection
} else {
// Serve static files
struct mg_http_serve_opts opts = {.root_dir = s_web_root};
@@ -37,7 +37,7 @@ static void timer_fn(void *arg) {
// Traverse over all connections
for (struct mg_connection *c = mgr->conns; c != NULL; c = c->next) {
// Send only to marked connections
if (c->label[0] == 'W') mg_ws_send(c, "hi", 2, WEBSOCKET_OP_TEXT);
if (c->data[0] == 'W') mg_ws_send(c, "hi", 2, WEBSOCKET_OP_TEXT);
}
}