#### Pre-Submission Checklist - [X] Commit message has the format required by CONTRIBUTING guide - [X] Commits are split per component (core, individual modules, libs, utils, ...) - [X] Each component has a single commit (if not, squash them into one commit) - [X] No commits to README files for modules (changes must be done to docbook files in `doc/` subfolder, the README file is autogenerated)
#### Type Of Change - [ ] Small bug fix (non-breaking change which fixes an issue) - [X] New feature (non-breaking change which adds new functionality) - [ ] Breaking change (fix or feature that would change existing functionality)
#### Checklist: - [ ] PR should be backported to stable branches - [X] Tested changes locally - [ ] Related to issue #XXXX (replace XXXX with an open issue number)
#### Description allow kamailio modules to be notified when a websocket is closed without depending on script callbacks. this allows for multiple independent modules to subscribe to new core event `SREV_TCP_WS_CLOSE` You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/2397
-- Commit Summary --
* core: add websocket event * websocket: emit core event on close
-- File Changes --
M src/core/events.c (20) M src/core/events.h (2) M src/modules/websocket/ws_conn.c (21)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/2397.patch https://github.com/kamailio/kamailio/pull/2397.diff
@miconda commented on this pull request.
@@ -261,6 +262,24 @@ int wsconn_add(struct receive_info *rcv, unsigned int sub_protocol)
return 0; }
+static void wsconn_run_close_callback(ws_connection_t *wsc) +{ + sip_msg_t *fmsg; + sr_event_param_t evp = {0}; + if(faked_msg_init() < 0) { + LM_ERR("faked_msg_init() failed\n"); + return; + } + fmsg = faked_msg_next(); + wsc->rcv.proto_reserved1 = wsc->id; + fmsg->rcv = wsc->rcv; +
Changes to fmsg content should be avoided, because the structure content is reused for following execution cycles, and that can also happen in another module.
There is evp.rcv field for the purpose of passing the received info via callback, any reason not using it?
The alternative is to backup fmsg->rcv to a local variable and restore after the sr_event_exec.
@lazedo pushed 1 commit.
4934651fd555e939e45a2baa13f8372635f757db websocket: emit core event on close
@miconda any other comments or can this be merged ?
Can be merged.
Merged #2397 into master.