Skip to content

Commit a7a7904

Browse files
authored
add client disconnect reason text in SocketIOclient events (#971)
* add client disconnect reason text in SocketIOclient events
1 parent 8d0744e commit a7a7904

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/SocketIOclient.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,13 @@ void SocketIOclient::loop(void) {
188188
void SocketIOclient::handleCbEvent(WStype_t type, uint8_t * payload, size_t length) {
189189
switch(type) {
190190
case WStype_DISCONNECTED:
191-
runIOCbEvent(sIOtype_DISCONNECT, NULL, 0);
192-
DEBUG_WEBSOCKETS("[wsIOc] Disconnected!\n");
191+
if(payload && length > 0) {
192+
runIOCbEvent(sIOtype_DISCONNECT, payload, length);
193+
DEBUG_WEBSOCKETS("[wsIOc] Disconnected! reason: %s\n", payload);
194+
} else {
195+
runIOCbEvent(sIOtype_DISCONNECT, NULL, 0);
196+
DEBUG_WEBSOCKETS("[wsIOc] Disconnected!\n");
197+
}
193198
break;
194199
case WStype_CONNECTED: {
195200
DEBUG_WEBSOCKETS("[wsIOc] Connected to url: %s\n", payload);

0 commit comments

Comments
 (0)