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_server.cpp | |
parent | 5d91e87c64f757fb1c20f43a0a30db3c73073625 (diff) |
Implement WebSocket clean close detection.
Diffstat (limited to 'modules/websocket/lws_server.cpp')
-rw-r--r-- | modules/websocket/lws_server.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/modules/websocket/lws_server.cpp b/modules/websocket/lws_server.cpp index d13a8024fb..58fa043346 100644 --- a/modules/websocket/lws_server.cpp +++ b/modules/websocket/lws_server.cpp @@ -90,6 +90,7 @@ int LWSServer::_handle_cb(struct lws *wsi, enum lws_callback_reasons reason, voi peer_data->peer_id = id; peer_data->force_close = false; + peer_data->clean_close = false; _on_connect(id, lws_get_protocol(wsi)->name); break; } @@ -103,6 +104,7 @@ int LWSServer::_handle_cb(struct lws *wsi, enum lws_callback_reasons reason, voi int code; Ref<LWSPeer> peer = _peer_map[id]; String reason = peer->get_close_reason(in, len, code); + peer_data->clean_close = true; _on_close_request(id, code, reason); } return 0; @@ -112,11 +114,12 @@ int LWSServer::_handle_cb(struct lws *wsi, enum lws_callback_reasons reason, voi if (peer_data == NULL) return 0; int32_t id = peer_data->peer_id; + bool clean = peer_data->clean_close; if (_peer_map.has(id)) { _peer_map[id]->close(); _peer_map.erase(id); } - _on_disconnect(id); + _on_disconnect(id, clean); return 0; // we can end here } |