mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2025-12-13 02:52:11 +01:00
Stream all responses. Fix missing ETH IP address #310
This commit is contained in:
parent
6ba354c7ff
commit
026f9315b1
19 changed files with 1361 additions and 456 deletions
61
Sockets.h
61
Sockets.h
|
|
@ -1,4 +1,5 @@
|
|||
#include <WebSocketsServer.h>
|
||||
#include "WResp.h"
|
||||
#ifndef sockets_h
|
||||
#define sockets_h
|
||||
|
||||
|
|
@ -6,31 +7,70 @@
|
|||
#define ROOM_EMIT_FRAME 0
|
||||
|
||||
struct room_t {
|
||||
uint8_t clients[5] = {255, 255, 255, 255};
|
||||
uint8_t clients[5] = {255, 255, 255, 255, 255};
|
||||
uint8_t activeClients();
|
||||
bool isJoined(uint8_t num);
|
||||
bool join(uint8_t num);
|
||||
bool leave(uint8_t num);
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
class ClientSocketEvent {
|
||||
private:
|
||||
uint8_t _objects = 0;
|
||||
uint8_t _arrays = 0;
|
||||
bool _nocomma = true;
|
||||
char _numbuff[25] = {0};
|
||||
protected:
|
||||
void _safecat(const char *val, bool escape = false);
|
||||
void _appendNumber(const char *name);
|
||||
public:
|
||||
ClientSocketEvent();
|
||||
ClientSocketEvent(const char *evt);
|
||||
ClientSocketEvent(const char *evt, const char *data);
|
||||
char msg[2048];
|
||||
//ClientSocketEvent(const char *evt, const char *data);
|
||||
char msg[2048] = "";
|
||||
void beginEmit(const char *evt);
|
||||
void endEmit();
|
||||
|
||||
void prepareMessage(const char *evt, const char *data);
|
||||
void prepareMessage(const char *evt, JsonDocument &doc);
|
||||
void appendMessage(const char *text);
|
||||
void appendElement(const char *elem, const char *val);
|
||||
|
||||
void beginObject(const char *name = nullptr);
|
||||
void endObject();
|
||||
void beginArray(const char *name = nullptr);
|
||||
void endArray();
|
||||
|
||||
void appendElem(const char *name = nullptr);
|
||||
void addElem(const char* val);
|
||||
void addElem(float fval);
|
||||
void addElem(int8_t nval);
|
||||
void addElem(uint8_t nval);
|
||||
void addElem(int16_t nval);
|
||||
void addElem(uint16_t nval);
|
||||
void addElem(int32_t nval);
|
||||
void addElem(uint32_t nval);
|
||||
void addElem(int64_t lval);
|
||||
void addElem(uint64_t lval);
|
||||
void addElem(bool bval);
|
||||
|
||||
|
||||
void addElem(const char* name, float fval);
|
||||
void addElem(const char* name, int8_t nval);
|
||||
void addElem(const char* name, uint8_t nval);
|
||||
void addElem(const char* name, int16_t nval);
|
||||
void addElem(const char* name, uint16_t nval);
|
||||
void addElem(const char* name, int32_t nval);
|
||||
void addElem(const char* name, uint32_t nval);
|
||||
void addElem(const char* name, int64_t lval);
|
||||
void addElem(const char* name, uint64_t lval);
|
||||
void addElem(const char* name, bool bval);
|
||||
void addElem(const char *name, const char *val);
|
||||
};
|
||||
*/
|
||||
class SocketEmitter {
|
||||
ClientSocketEvent evt;
|
||||
|
||||
public:
|
||||
JsonSockEvent json;
|
||||
//ClientSocketEvent evt;
|
||||
room_t rooms[SOCK_MAX_ROOMS];
|
||||
uint8_t activeClients(uint8_t room);
|
||||
void startup();
|
||||
|
|
@ -38,6 +78,10 @@ class SocketEmitter {
|
|||
void loop();
|
||||
void end();
|
||||
void disconnect();
|
||||
JsonSockEvent * beginEmit(const char *evt);
|
||||
void endEmit(uint8_t num = 255);
|
||||
void endEmitRoom(uint8_t num);
|
||||
/*
|
||||
bool sendToRoom(uint8_t room, ClientSocketEvent *evt);
|
||||
bool sendToClients(ClientSocketEvent *evt);
|
||||
bool sendToClient(uint8_t num, ClientSocketEvent *evt);
|
||||
|
|
@ -45,6 +89,7 @@ class SocketEmitter {
|
|||
bool sendToClient(uint8_t num, const char *evt, const char *data);
|
||||
bool sendToClients(const char *evt, JsonDocument &doc);
|
||||
bool sendToClient(uint8_t num, const char *evt, JsonDocument &doc);
|
||||
*/
|
||||
static void wsEvent(uint8_t num, WStype_t type, uint8_t *payload, size_t length);
|
||||
};
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue