Skip to content

Commit

Permalink
websocket: emit core event on close
Browse files Browse the repository at this point in the history
  • Loading branch information
lazedo committed Jul 16, 2020
1 parent 815b8de commit 1691478
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/modules/websocket/ws_conn.c
Expand Up @@ -31,6 +31,7 @@
#include "../../core/counters.h"
#include "../../core/kemi.h"
#include "../../core/mem/mem.h"
#include "../../core/events.h"
#include "ws_conn.h"
#include "websocket.h"

Expand Down Expand Up @@ -261,6 +262,14 @@ int wsconn_add(struct receive_info *rcv, unsigned int sub_protocol)
return 0;
}

static void wsconn_run_close_callback(ws_connection_t *wsc)
{
sr_event_param_t evp = {0};
wsc->rcv.proto_reserved1 = wsc->id;
evp.rcv = &wsc->rcv;
sr_event_exec(SREV_TCP_WS_CLOSE, &evp);
}

static void wsconn_run_route(ws_connection_t *wsc)
{
int rt, backup_rt;
Expand Down Expand Up @@ -321,6 +330,8 @@ static void wsconn_dtor(ws_connection_t *wsc)
if(wsc->run_event)
wsconn_run_route(wsc);

wsconn_run_close_callback(wsc);

shm_free(wsc);

LM_DBG("wsconn_dtor for [%p] destroyed\n", wsc);
Expand Down

0 comments on commit 1691478

Please sign in to comment.