diff --git a/src/WebSockets.h b/src/WebSockets.h index 35d7d8c..00d65b2 100644 --- a/src/WebSockets.h +++ b/src/WebSockets.h @@ -258,11 +258,7 @@ typedef struct { uint8_t * maskKey; } WSMessageHeader_t; -struct WSclient_t { - - WSclient_t (): status(WSC_NOT_CONNECTED) - { - } +typedef struct { void init (uint8_t num, uint32_t pingInterval, @@ -275,34 +271,34 @@ struct WSclient_t { this->disconnectTimeoutCount = disconnectTimeoutCount; } - uint8_t num; ///< connection number + uint8_t num = 0; ///< connection number - WSclientsStatus_t status; + WSclientsStatus_t status = WSC_NOT_CONNECTED; - WEBSOCKETS_NETWORK_CLASS * tcp; + WEBSOCKETS_NETWORK_CLASS * tcp = nullptr; - bool isSocketIO; ///< client for socket.io server + bool isSocketIO = false; ///< client for socket.io server #if defined(HAS_SSL) - bool isSSL; ///< run in ssl mode + bool isSSL = false; ///< run in ssl mode WEBSOCKETS_NETWORK_SSL_CLASS * ssl; #endif - String cUrl; ///< http url - uint16_t cCode; ///< http code + String cUrl; ///< http url + uint16_t cCode = 0; ///< http code bool cIsClient = false; ///< will be used for masking - bool cIsUpgrade; ///< Connection == Upgrade - bool cIsWebsocket; ///< Upgrade == websocket + bool cIsUpgrade = false; ///< Connection == Upgrade + bool cIsWebsocket = false; ///< Upgrade == websocket String cSessionId; ///< client Set-Cookie (session id) String cKey; ///< client Sec-WebSocket-Key String cAccept; ///< client Sec-WebSocket-Accept String cProtocol; ///< client Sec-WebSocket-Protocol String cExtensions; ///< client Sec-WebSocket-Extensions - uint16_t cVersion; ///< client Sec-WebSocket-Version + uint16_t cVersion = 0; ///< client Sec-WebSocket-Version - uint8_t cWsRXsize; ///< State of the RX + uint8_t cWsRXsize = 0; ///< State of the RX uint8_t cWsHeader[WEBSOCKETS_MAX_HEADER_SIZE]; ///< RX WS Message buffer WSMessageHeader_t cWsHeaderDecode; @@ -311,21 +307,21 @@ struct WSclient_t { String extraHeaders; - bool cHttpHeadersValid; ///< non-websocket http header validity indicator + bool cHttpHeadersValid = false; ///< non-websocket http header validity indicator size_t cMandatoryHeadersCount; ///< non-websocket mandatory http headers present count - bool pongReceived; - uint32_t pingInterval; // how often ping will be sent, 0 means "heartbeat is not active" - uint32_t lastPing; // millis when last pong has been received - uint32_t pongTimeout; // interval in millis after which pong is considered to timeout - uint8_t disconnectTimeoutCount; // after how many subsequent pong timeouts discconnect will happen, 0 means "do not disconnect" - uint8_t pongTimeoutCount; // current pong timeout count + bool pongReceived = false; + uint32_t pingInterval = 0; // how often ping will be sent, 0 means "heartbeat is not active" + uint32_t lastPing = 0; // millis when last pong has been received + uint32_t pongTimeout = 0; // interval in millis after which pong is considered to timeout + uint8_t disconnectTimeoutCount = 0; // after how many subsequent pong timeouts discconnect will happen, 0 means "do not disconnect" + uint8_t pongTimeoutCount = 0; // current pong timeout count #if(WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266_ASYNC) String cHttpLine; ///< HTTP header lines #endif -}; +} WSclient_t; class WebSockets { protected: