Browse code

core: added event callback field for tcp closed connection

Armen Babikyan authored on 04/01/2016 22:04:37 • Daniel-Constantin Mierla committed on 04/01/2016 22:04:37
Showing 2 changed files
... ...
@@ -165,6 +165,11 @@ int sr_event_register_cb(int type, sr_event_cb_f f)
165 165
 					_sr_events_list.rcv_nosip = f;
166 166
 				else return -1;
167 167
 			break;
168
+		case SREV_TCP_CLOSED:
169
+				if(_sr_events_list.tcp_closed==0)
170
+					_sr_events_list.tcp_closed = f;
171
+				else return -1;
172
+			break;
168 173
 		default:
169 174
 			return -1;
170 175
 	}
... ...
@@ -284,6 +289,12 @@ int sr_event_exec(int type, void *data)
284 289
 					ret = _sr_events_list.rcv_nosip(data);
285 290
 					return ret;
286 291
 				} else return 1;
292
+		case SREV_TCP_CLOSED:
293
+				if(unlikely(_sr_events_list.tcp_closed!=0))
294
+				{
295
+					ret = _sr_events_list.tcp_closed(data);
296
+					return ret;
297
+				} else return 1;
287 298
 		default:
288 299
 			return -1;
289 300
 	}
... ...
@@ -319,6 +330,8 @@ int sr_event_enabled(int type)
319 330
 				return (_sr_events_list.stun_in!=0)?1:0;
320 331
 		case SREV_RCV_NOSIP:
321 332
 				return (_sr_events_list.rcv_nosip!=0)?1:0;
333
+		case SREV_TCP_CLOSED:
334
+				return (_sr_events_list.tcp_closed!=0)?1:0;
322 335
 	}
323 336
 	return 0;
324 337
 }
... ...
@@ -34,6 +34,7 @@
34 34
 #define SREV_TCP_WS_FRAME_IN		10
35 35
 #define SREV_TCP_WS_FRAME_OUT		11
36 36
 #define SREV_STUN_IN			12
37
+#define SREV_TCP_CLOSED			13
37 38
 
38 39
 #define SREV_CB_LIST_SIZE	3
39 40
 
... ...
@@ -52,6 +53,7 @@ typedef struct sr_event_cb {
52 53
 	sr_event_cb_f tcp_ws_frame_out;
53 54
 	sr_event_cb_f stun_in;
54 55
 	sr_event_cb_f rcv_nosip;
56
+	sr_event_cb_f tcp_closed;
55 57
 } sr_event_cb_t;
56 58
 
57 59
 void sr_event_cb_init(void);