mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-23 20:11:49 +00:00
Use mg_str, not pointers, in mg_mqtt_{sub,pub}
This commit is contained in:
1 parent
fe813ee247
commit
226917e1cd
9 files changed
+45
-48
No files matched your search
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user