mirror of
https://github.com/Links2004/arduinoWebSockets.git
synced 2025-07-13 15:26:31 +02:00
message browser to client working
This commit is contained in:
@ -27,13 +27,67 @@
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#ifdef ESP8266
|
||||
#include <ESP8266WiFi.h>
|
||||
#else
|
||||
#include <UIPEthernet.h>
|
||||
#ifndef UIPETHERNET_H
|
||||
#include <Ethernet.h>
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define DEBUG_WEBSOCKETS(...) Serial1.printf( __VA_ARGS__ ); Serial1.flush()
|
||||
|
||||
#ifndef DEBUG_WEBSOCKETS
|
||||
#define DEBUG_WEBSOCKETS(...)
|
||||
#endif
|
||||
|
||||
#define WEBSOCKETS_MAX_DATA_SIZE (15*1024)
|
||||
#define WEBSOCKETS_TCP_TIMEOUT (1000)
|
||||
|
||||
typedef enum {
|
||||
WSC_NOT_CONNECTED,
|
||||
WSC_HEADER,
|
||||
WSC_CONNECTED
|
||||
} WSclientsStatus_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t num; ///< connection number
|
||||
|
||||
WSclientsStatus_t status;
|
||||
#ifdef ESP8266
|
||||
WiFiClient tcp;
|
||||
#else
|
||||
#ifdef UIPETHERNET_H
|
||||
UIPClient tcp;
|
||||
#else
|
||||
EthernetClient tcp;
|
||||
#endif
|
||||
#endif
|
||||
String cUrl; ///< http url
|
||||
|
||||
bool cIsUpgrade; ///< Connection == Upgrade
|
||||
bool cIsWebsocket; ///< Upgrade == websocket
|
||||
|
||||
String cKey; ///< client Sec-WebSocket-Key
|
||||
String cProtocol; ///< client Sec-WebSocket-Protocol
|
||||
String cExtensions; ///< client Sec-WebSocket-Extensions
|
||||
int cVersion; ///< client Sec-WebSocket-Version
|
||||
|
||||
String sKey; ///< server Sec-WebSocket-Key
|
||||
|
||||
} WSclient_t;
|
||||
|
||||
class WebSockets {
|
||||
protected:
|
||||
|
||||
void handleWebsocket(WSclient_t * client);
|
||||
|
||||
virtual void clientDisconnect(WSclient_t * client);
|
||||
virtual bool clientIsConnected(WSclient_t * client);
|
||||
|
||||
bool readWait(WSclient_t * client, uint8_t *out, size_t n);
|
||||
};
|
||||
|
||||
#endif /* WEBSOCKETS_H_ */
|
||||
|
Reference in New Issue
Block a user