Handle #1502 - send CLOSE when CLOSE is received

This commit is contained in:
Sergey Lyubka 2022-04-05 14:45:39 +01:00
parent d11173fe90
commit 2f77855ec1
2 changed files with 4 additions and 2 deletions

View File

@ -4996,7 +4996,8 @@ static void mg_ws_cb(struct mg_connection *c, int ev, void *ev_data,
case WEBSOCKET_OP_CLOSE:
MG_DEBUG(("%lu Got WS CLOSE", c->id));
mg_call(c, MG_EV_WS_CTL, &m);
c->is_closing = 1;
mg_ws_send(c, "", 0, WEBSOCKET_OP_CLOSE);
c->is_draining = 1;
break;
default:
// Per RFC6455, close conn when an unknown op is recvd

View File

@ -174,7 +174,8 @@ static void mg_ws_cb(struct mg_connection *c, int ev, void *ev_data,
case WEBSOCKET_OP_CLOSE:
MG_DEBUG(("%lu Got WS CLOSE", c->id));
mg_call(c, MG_EV_WS_CTL, &m);
c->is_closing = 1;
mg_ws_send(c, "", 0, WEBSOCKET_OP_CLOSE);
c->is_draining = 1;
break;
default:
// Per RFC6455, close conn when an unknown op is recvd