1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

LWS_CALLBACK_CLIENT_CLOSED: split out client and server CLOSE callback

Until now LWS_CALLBACK_CLOSED has served the same for
client and server connections.  This introduces a new
LWS_CALLBACK_CLIENT_CLOSE which is sent on established
ws client connections, insread of LWS_CALLBACK_CLOSED.

LWS_CALLBACK_CLOSED continues to be sent when server
ws connections close.
This commit is contained in:
Andy Green 2018-03-14 17:30:22 +08:00
parent 302f8fad82
commit 2b932c500f
3 changed files with 9 additions and 3 deletions

View file

@ -852,8 +852,12 @@ just_kill_connection:
wsi->protocol->callback &&
wsi->mode != LWSCM_RAW &&
(wsi->state_pre_close & _LSF_CCB)) {
wsi->protocol->callback(wsi, LWS_CALLBACK_CLOSED,
wsi->user_space, NULL, 0);
if (wsi->mode == LWSCM_WS_CLIENT)
wsi->protocol->callback(wsi, LWS_CALLBACK_CLIENT_CLOSED,
wsi->user_space, NULL, 0);
else
wsi->protocol->callback(wsi, LWS_CALLBACK_CLOSED,
wsi->user_space, NULL, 0);
} else if (wsi->mode == LWSCM_HTTP_SERVING_ACCEPTED) {
lwsl_debug("calling back CLOSED_HTTP\n");
wsi->vhost->protocols->callback(wsi, LWS_CALLBACK_CLOSED_HTTP,

View file

@ -1462,6 +1462,8 @@ enum lws_callback_reasons {
* reported to the vhost in question here, including completion
* and failure. in points to optional JSON, and len represents the
* connection state using enum lws_cert_update_state */
LWS_CALLBACK_CLIENT_CLOSED = 75,
/**< when a client websocket session ends */
/****** add new things just above ---^ ******/

View file

@ -42,7 +42,7 @@ callback_dumb_increment(struct lws *wsi, enum lws_callback_reasons reason,
lwsl_user("RX: %s\n", (const char *)in);
break;
case LWS_CALLBACK_CLOSED:
case LWS_CALLBACK_CLIENT_CLOSED:
client_wsi = NULL;
break;