Use mg_str, not pointers, in mg_mqtt_{sub,pub}

This commit is contained in:
Sergey Lyubka committed 2022-01-19 09:57:27 +00:00
1 parent fe813ee247
commit 226917e1cd
9 files changed
+45 -48

No files matched your search

+2 -2
View File
@@ -46,10 +46,10 @@ static void fn(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
struct mg_str topic = mg_str(s_topic), data = mg_str("hello");
size_t len = c->send.len;
LOG(LL_INFO, ("CONNECTED to %s", s_url));
mg_mqtt_sub(c, &topic, 1);
mg_mqtt_sub(c, topic, 1);
mg_ws_wrap(c, len, WEBSOCKET_OP_BINARY);
LOG(LL_INFO, ("SUBSCRIBED to %.*s", (int) topic.len, topic.ptr));
mg_mqtt_pub(c, &topic, &data, 1, false);
mg_mqtt_pub(c, topic, data, 1, false);
LOG(LL_INFO, ("PUBSLISHED %.*s -> %.*s", (int) data.len, data.ptr,
(int) topic.len, topic.ptr));
len = mg_ws_wrap(c, c->send.len - len, WEBSOCKET_OP_BINARY);