Skip to content

Commit

Permalink
websocket to ver 2.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jhagas committed Jul 17, 2024
1 parent 43b2cd2 commit b2b45fa
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 46 deletions.
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"examples": "examples/*/*.ino",
"dependencies": {
"bblanchon/ArduinoJson": "^7.1.0",
"links2004/WebSockets": "^2.4.2"
"links2004/WebSockets": "^2.4.1"
},
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ paragraph=This allows developers to interface their ESP32/ESP8266 with Supabase,
category=Other
url=https://github.com/jhagas/ESP32-Supabase
architectures=*
depends=ArduinoJson (>=7.1.0), WebSockets (>=2.4.2)
depends=ArduinoJson (>=7.1.0), WebSockets (>=2.4.1)
4 changes: 2 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ board = esp32doit-devkit-v1
framework = arduino
lib_deps =
bblanchon/ArduinoJson @ ^7.1.0
links2004/WebSockets@^2.4.2
links2004/WebSockets@^2.4.1
build_flags = ${config.build_flags}
build_src_filter = ${config.src_filter}

Expand All @@ -36,6 +36,6 @@ board = nodemcuv2
framework = arduino
lib_deps =
bblanchon/ArduinoJson @ ^7.1.0
links2004/WebSockets@^2.4.2
links2004/WebSockets@^2.4.1
build_flags = ${config.build_flags}
build_src_filter = ${config.src_filter}
84 changes: 42 additions & 42 deletions src/ESP-Supabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,48 @@ struct SupabaseQuery
String value;
};

class SupabaseRealtimeTableEntry
{
private:
WiFiClientSecure client;
WebSocketsClient webSocket;
std::function<void(JsonDocument)> handleEvent; // Changed to std::function
String jsonRealtimeConfig;
String key;
String hostname;

public:
void setupHandler(std::function<void(JsonDocument)> handler);

SupabaseRealtimeTableEntry(String key, String hostname)
{
hostname.replace("https://", "");
this->key = key;
this->hostname = hostname;
}

void setupListener(String table, String event, SupabaseQuery queries[], int numqueries);
void processMessage(uint8_t *payload, size_t length, JsonDocument result);
void webSocketEvent(WStype_t type, uint8_t *payload, size_t length);
void loop();
};

class SupabaseRealtime
{
private:
String hostname;
String key;
// Define an array to store SUPABASERealtimeTableEntry objects
std::vector<SupabaseRealtimeTableEntry> entries;

public:
SupabaseRealtime(){}
void setupConnection(String hostname, String key);
// Function to add a SUPABASERealtimeTableEntry object to the array
void addEntry(String table, String event, SupabaseQuery queries[], int numqueries, std::function<void(JsonDocument)> handler);\
void loop();
};

class Supabase
{
private:
Expand Down Expand Up @@ -100,46 +142,4 @@ class Supabase
String rpc(String func_name, String json_param = "");
};

class SupabaseRealtimeTableEntry
{
private:
WiFiClientSecure client;
WebSocketsClient webSocket;
std::function<void(JsonDocument)> handleEvent; // Changed to std::function
String jsonRealtimeConfig;
String key;
String hostname;

public:
void setupHandler(std::function<void(JsonDocument)> handler);

SupabaseRealtimeTableEntry(String key, String hostname)
{
hostname.replace("https://", "");
this->key = key;
this->hostname = hostname;
}

void setupListener(String table, String event, SupabaseQuery queries[], int numqueries);
void processMessage(uint8_t *payload, size_t length, JsonDocument result);
void webSocketEvent(WStype_t type, uint8_t *payload, size_t length);
void loop();
};

class SupabaseRealtime
{
private:
String hostname;
String key;
// Define an array to store SUPABASERealtimeTableEntry objects
std::vector<SupabaseRealtimeTableEntry> entries;

public:
SupabaseRealtime(){}
void setupConnection(String hostname, String key);
// Function to add a SUPABASERealtimeTableEntry object to the array
void addEntry(String table, String event, SupabaseQuery queries[], int numqueries, std::function<void(JsonDocument)> handler);\
void loop();
};

#endif

0 comments on commit b2b45fa

Please sign in to comment.