Module: kamailio
Branch: master
Commit: 815b8dee38df74395d4e840db3dc582695c02baa
URL:
https://github.com/kamailio/kamailio/commit/815b8dee38df74395d4e840db3dc582…
Author: lazedo <luis.azedo(a)factorlusitano.com>
Committer: lazedo <luis.azedo(a)factorlusitano.com>
Date: 2020-07-16T21:55:15Z
core: add websocket event
* allows multiple consumers
* returns last result
---
Modified: src/core/events.c
Modified: src/core/events.h
---
Diff:
https://github.com/kamailio/kamailio/commit/815b8dee38df74395d4e840db3dc582…
Patch:
https://github.com/kamailio/kamailio/commit/815b8dee38df74395d4e840db3dc582…
---
diff --git a/src/core/events.c b/src/core/events.c
index 91df673996..2d8400f829 100644
--- a/src/core/events.c
+++ b/src/core/events.c
@@ -189,6 +189,15 @@ int sr_event_register_cb(int type, sr_event_cb_f f)
}
if(i==SREV_CB_LIST_SIZE) return -1;
break;
+ case SREV_TCP_WS_CLOSE:
+ for(i=0; i<SREV_CB_LIST_SIZE; i++) {
+ if(_sr_events_list.tcp_ws_close[i]==0) {
+ _sr_events_list.tcp_ws_close[i] = f;
+ break;
+ }
+ }
+ if(i==SREV_CB_LIST_SIZE) return -1;
+ break;
default:
return -1;
}
@@ -335,6 +344,15 @@ int sr_event_exec(int type, sr_event_param_t *evp)
ret |= _sr_events_list.sip_reply_out[i](evp);
}
} else return 1;
+ case SREV_TCP_WS_CLOSE:
+ if(unlikely(_sr_events_list.tcp_ws_close[0]!=0))
+ {
+ ret = 0;
+ for(i=0; i<SREV_CB_LIST_SIZE
+ && _sr_events_list.tcp_ws_close[i]; i++) {
+ ret = _sr_events_list.tcp_ws_close[i](evp);
+ }
+ } else return 1;
default:
return -1;
}
@@ -378,6 +396,8 @@ int sr_event_enabled(int type)
return (_sr_events_list.net_data_send!=0)?1:0;
case SREV_SIP_REPLY_OUT:
return (_sr_events_list.sip_reply_out[0]!=0)?1:0;
+ case SREV_TCP_WS_CLOSE:
+ return (_sr_events_list.tcp_ws_close[0]!=0)?1:0;
}
return 0;
}
diff --git a/src/core/events.h b/src/core/events.h
index 2208d8038d..4d53067dba 100644
--- a/src/core/events.h
+++ b/src/core/events.h
@@ -38,6 +38,7 @@
#define SREV_NET_DATA_RECV 14
#define SREV_NET_DATA_SEND 15
#define SREV_SIP_REPLY_OUT 16
+#define SREV_TCP_WS_CLOSE 17
#define SREV_CB_LIST_SIZE 8
@@ -71,6 +72,7 @@ typedef struct sr_event_cb {
sr_event_cb_f net_data_recv;
sr_event_cb_f net_data_send;
sr_event_cb_f sip_reply_out[SREV_CB_LIST_SIZE];
+ sr_event_cb_f tcp_ws_close[SREV_CB_LIST_SIZE];
} sr_event_cb_t;
void sr_event_cb_init(void);