Module: kamailio
Branch: master
Commit: 16914788ba49b69aaabc8e75ca9b5d95dce6b825
URL:
https://github.com/kamailio/kamailio/commit/16914788ba49b69aaabc8e75ca9b5d9…
Author: lazedo <luis.azedo(a)factorlusitano.com>
Committer: lazedo <luis.azedo(a)factorlusitano.com>
Date: 2020-07-16T21:55:15Z
websocket: emit core event on close
---
Modified: src/modules/websocket/ws_conn.c
---
Diff:
https://github.com/kamailio/kamailio/commit/16914788ba49b69aaabc8e75ca9b5d9…
Patch:
https://github.com/kamailio/kamailio/commit/16914788ba49b69aaabc8e75ca9b5d9…
---
diff --git a/src/modules/websocket/ws_conn.c b/src/modules/websocket/ws_conn.c
index 8570afa086..7ffedd9be5 100644
--- a/src/modules/websocket/ws_conn.c
+++ b/src/modules/websocket/ws_conn.c
@@ -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"
@@ -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;
@@ -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);