mirror of
https://github.com/cesanta/mongoose.git
synced 2025-01-14 09:48:01 +08:00
Echo WS CLOSE payload back
This commit is contained in:
parent
cfe2e83e6b
commit
ce8fa4c24b
@ -5812,9 +5812,10 @@ static void mg_ws_cb(struct mg_connection *c, int ev, void *ev_data,
|
||||
if (final) mg_call(c, MG_EV_WS_MSG, &m);
|
||||
break;
|
||||
case WEBSOCKET_OP_CLOSE:
|
||||
MG_DEBUG(("%lu Got WS CLOSE", c->id));
|
||||
MG_DEBUG(("%lu WS CLOSE", c->id));
|
||||
mg_call(c, MG_EV_WS_CTL, &m);
|
||||
mg_ws_send(c, "", 0, WEBSOCKET_OP_CLOSE);
|
||||
// Echo the payload of the received CLOSE message back to the sender
|
||||
mg_ws_send(c, m.data.ptr, m.data.len, WEBSOCKET_OP_CLOSE);
|
||||
c->is_draining = 1;
|
||||
break;
|
||||
default:
|
||||
|
5
src/ws.c
5
src/ws.c
@ -192,9 +192,10 @@ static void mg_ws_cb(struct mg_connection *c, int ev, void *ev_data,
|
||||
if (final) mg_call(c, MG_EV_WS_MSG, &m);
|
||||
break;
|
||||
case WEBSOCKET_OP_CLOSE:
|
||||
MG_DEBUG(("%lu Got WS CLOSE", c->id));
|
||||
MG_DEBUG(("%lu WS CLOSE", c->id));
|
||||
mg_call(c, MG_EV_WS_CTL, &m);
|
||||
mg_ws_send(c, "", 0, WEBSOCKET_OP_CLOSE);
|
||||
// Echo the payload of the received CLOSE message back to the sender
|
||||
mg_ws_send(c, m.data.ptr, m.data.len, WEBSOCKET_OP_CLOSE);
|
||||
c->is_draining = 1;
|
||||
break;
|
||||
default:
|
||||
|
Loading…
x
Reference in New Issue
Block a user