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
@@ -15,7 +15,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, "/api/watch")) {
mg_ws_upgrade(c, hm, NULL); // Upgrade HTTP to Websocket
c->label[0] = 'W'; // Set some unique mark on the connection
c->data[0] = 'W'; // Set some unique mark on the connection
} else {
struct mg_http_serve_opts opts = {.root_dir = s_web_root};
mg_http_serve_dir(c, ev_data, &opts);
@@ -28,7 +28,7 @@ static void fn(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
static void push(struct mg_mgr *mgr, const char *name, const void *data) {
struct mg_connection *c;
for (c = mgr->conns; c != NULL; c = c->next) {
if (c->label[0] != 'W') continue;
if (c->data[0] != 'W') continue;
mg_ws_printf(c, WEBSOCKET_OP_TEXT, "{%Q:%Q,%Q:%Q}", "name", name, "data",
data);
}