diff options
| author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2018-09-24 00:58:28 +0200 |
|---|---|---|
| committer | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2018-09-24 01:50:37 +0200 |
| commit | 4b92956db7cb479a1c3ee63f102f9866fbbc6fef (patch) | |
| tree | ecf842646ec674185988a4e140fd5f8c6a1b628d /modules/websocket/lws_client.cpp | |
| parent | 5d91e87c64f757fb1c20f43a0a30db3c73073625 (diff) | |
| download | redot-engine-4b92956db7cb479a1c3ee63f102f9866fbbc6fef.tar.gz | |
Implement WebSocket clean close detection.
Diffstat (limited to 'modules/websocket/lws_client.cpp')
| -rw-r--r-- | modules/websocket/lws_client.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/modules/websocket/lws_client.cpp b/modules/websocket/lws_client.cpp index a568b97a1a..cd814760e6 100644 --- a/modules/websocket/lws_client.cpp +++ b/modules/websocket/lws_client.cpp @@ -129,6 +129,7 @@ int LWSClient::_handle_cb(struct lws *wsi, enum lws_callback_reasons reason, voi peer->set_wsi(wsi); peer_data->peer_id = 0; peer_data->force_close = false; + peer_data->clean_close = false; _on_connect(lws_get_protocol(wsi)->name); break; @@ -140,6 +141,7 @@ int LWSClient::_handle_cb(struct lws *wsi, enum lws_callback_reasons reason, voi case LWS_CALLBACK_WS_PEER_INITIATED_CLOSE: { int code; String reason = peer->get_close_reason(in, len, code); + peer_data->clean_close = true; _on_close_request(code, reason); return 0; } @@ -147,7 +149,7 @@ int LWSClient::_handle_cb(struct lws *wsi, enum lws_callback_reasons reason, voi case LWS_CALLBACK_CLIENT_CLOSED: peer->close(); destroy_context(); - _on_disconnect(); + _on_disconnect(peer_data->clean_close); return 0; // We can end here case LWS_CALLBACK_CLIENT_RECEIVE: |
