Browse code

core: added event callback field for tcp closed connection

Armen Babikyan authored 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 284
 					ret = _sr_events_list.rcv_nosip(data);
285 285
 					return ret;
286 286
 				} else return 1;
287
+		case SREV_TCP_CLOSED:
288
+				if(unlikely(_sr_events_list.tcp_closed!=0))
289
+				{
290
+					ret = _sr_events_list.tcp_closed(data);
291
+					return ret;
292
+				} else return 1;
287 293
 		default:
288 294
 			return -1;
289 295
 	}
... ...
@@ -319,6 +330,8 @@ int sr_event_enabled(int type)
319 319
 				return (_sr_events_list.stun_in!=0)?1:0;
320 320
 		case SREV_RCV_NOSIP:
321 321
 				return (_sr_events_list.rcv_nosip!=0)?1:0;
322
+		case SREV_TCP_CLOSED:
323
+				return (_sr_events_list.tcp_closed!=0)?1:0;
322 324
 	}
323 325
 	return 0;
324 326
 }
... ...
@@ -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 52
 	sr_event_cb_f tcp_ws_frame_out;
53 53
 	sr_event_cb_f stun_in;
54 54
 	sr_event_cb_f rcv_nosip;
55
+	sr_event_cb_f tcp_closed;
55 56
 } sr_event_cb_t;
56 57
 
57 58
 void sr_event_cb_init(void);