🛸 Use char* in favour of String
This commit is contained in:
@@ -82,7 +82,8 @@ void EventSocket::emit(const char *event, const char *payload, const char *origi
|
|||||||
xSemaphoreGive(clientSubscriptionsMutex);
|
xSemaphoreGive(clientSubscriptionsMutex);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String msg = "[\"" + String(event) + "\"," + String(payload) + "]";
|
char msg[strlen(event) + strlen(payload) + 10];
|
||||||
|
snprintf(msg, sizeof(msg), "[\"%s\",%s]", event, payload);
|
||||||
|
|
||||||
// if onlyToSameOrigin == true, send the message back to the origin
|
// if onlyToSameOrigin == true, send the message back to the origin
|
||||||
if (onlyToSameOrigin && originSubscriptionId > 0)
|
if (onlyToSameOrigin && originSubscriptionId > 0)
|
||||||
@@ -90,9 +91,8 @@ void EventSocket::emit(const char *event, const char *payload, const char *origi
|
|||||||
auto *client = _socket.getClient(originSubscriptionId);
|
auto *client = _socket.getClient(originSubscriptionId);
|
||||||
if (client)
|
if (client)
|
||||||
{
|
{
|
||||||
ESP_LOGV("EventSocket", "Emitting event: %s to %s, Message: %s", event, client->remoteIP().toString().c_str(),
|
ESP_LOGV("EventSocket", "Emitting event: %s to %s, Message: %s", event, client->remoteIP().toString().c_str(), msg);
|
||||||
msg.c_str());
|
client->sendMessage(msg);
|
||||||
client->sendMessage(msg.c_str());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -108,9 +108,8 @@ void EventSocket::emit(const char *event, const char *payload, const char *origi
|
|||||||
subscriptions.remove(subscription);
|
subscriptions.remove(subscription);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ESP_LOGV("EventSocket", "Emitting event: %s to %s, Message: %s", event, client->remoteIP().toString().c_str(),
|
ESP_LOGV("EventSocket", "Emitting event: %s to %s, Message: %s", event, client->remoteIP().toString().c_str(), msg);
|
||||||
msg.c_str());
|
client->sendMessage(msg);
|
||||||
client->sendMessage(msg.c_str());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xSemaphoreGive(clientSubscriptionsMutex);
|
xSemaphoreGive(clientSubscriptionsMutex);
|
||||||
|
|||||||
Reference in New Issue
Block a user