File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,8 @@ int WebSocketClient::begin(const char* aPath)
61
61
}
62
62
}
63
63
64
+ awaitingPong = false ;
65
+
64
66
iRxSize = 0 ;
65
67
66
68
// status code of 101 means success
@@ -257,6 +259,7 @@ int WebSocketClient::parseMessage()
257
259
}
258
260
else if (TYPE_PONG == messageType ())
259
261
{
262
+ awaitingPong = false ;
260
263
flushRx ();
261
264
iRxSize = 0 ;
262
265
}
@@ -302,11 +305,18 @@ int WebSocketClient::ping()
302
305
pingData[i] = random (0xff );
303
306
}
304
307
308
+ awaitingPong = true ;
309
+
305
310
beginMessage (TYPE_PING);
306
311
write (pingData, sizeof (pingData));
307
312
return endMessage ();
308
313
}
309
314
315
+ bool WebSocketClient::isAwaitingPong ()
316
+ {
317
+ return awaitingPong;
318
+ }
319
+
310
320
int WebSocketClient::available ()
311
321
{
312
322
if (iState < eReadingBody)
Original file line number Diff line number Diff line change @@ -68,6 +68,11 @@ class WebSocketClient : public HttpClient
68
68
*/
69
69
int ping ();
70
70
71
+ /* * Check if a pong has not yet been seen since last ping
72
+ @return true if awaiting a pong, otherwise false
73
+ */
74
+ bool isAwaitingPong ();
75
+
71
76
// Inherited from Print
72
77
virtual size_t write (uint8_t aByte);
73
78
virtual size_t write (const uint8_t *aBuffer, size_t aSize);
@@ -94,6 +99,8 @@ class WebSocketClient : public HttpClient
94
99
bool iRxMasked;
95
100
int iRxMaskIndex;
96
101
uint8_t iRxMaskKey[4 ];
102
+
103
+ bool awaitingPong;
97
104
};
98
105
99
106
#endif
You can’t perform that action at this time.
0 commit comments