🎨 Replace Arduino String with std::string
This commit is contained in:
@@ -6,11 +6,12 @@
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
enum message_type_t { CONNECT = 0, DISCONNECT = 1, EVENT = 2, PING = 3, PONG = 4, BINARY_EVENT = 5 };
|
||||
|
||||
typedef std::function<void(JsonVariant &root, int originId)> EventCallback;
|
||||
typedef std::function<void(const String &originId, bool sync)> SubscribeCallback;
|
||||
typedef std::function<void(const std::string &originId, bool sync)> SubscribeCallback;
|
||||
|
||||
class EventSocket {
|
||||
public:
|
||||
@@ -20,9 +21,9 @@ class EventSocket {
|
||||
|
||||
bool hasSubscribers(const char *event);
|
||||
|
||||
void onEvent(String event, EventCallback callback);
|
||||
void onEvent(std::string event, EventCallback callback);
|
||||
|
||||
void onSubscribe(String event, SubscribeCallback callback);
|
||||
void onSubscribe(std::string event, SubscribeCallback callback);
|
||||
|
||||
void emit(const char *event, JsonVariant &payload, const char *originId = "", bool onlyToSameOrigin = false);
|
||||
|
||||
@@ -31,12 +32,12 @@ class EventSocket {
|
||||
PsychicHttpServer &_server;
|
||||
const char *_route;
|
||||
|
||||
std::map<String, std::list<int>> client_subscriptions;
|
||||
std::map<String, std::list<EventCallback>> event_callbacks;
|
||||
std::map<String, std::list<SubscribeCallback>> subscribe_callbacks;
|
||||
void handleEventCallbacks(String event, JsonVariant &jsonObject, int originId);
|
||||
std::map<std::string, std::list<int>> client_subscriptions;
|
||||
std::map<std::string, std::list<EventCallback>> event_callbacks;
|
||||
std::map<std::string, std::list<SubscribeCallback>> subscribe_callbacks;
|
||||
void handleEventCallbacks(std::string event, JsonVariant &jsonObject, int originId);
|
||||
void send(PsychicWebSocketClient *client, const char *data, size_t len);
|
||||
void handleSubscribeCallbacks(String event, const String &originId);
|
||||
void handleSubscribeCallbacks(std::string event, const std::string &originId);
|
||||
|
||||
void onWSOpen(PsychicWebSocketClient *client);
|
||||
void onWSClose(PsychicWebSocketClient *client);
|
||||
|
||||
Reference in New Issue
Block a user