Browse code

core: new event SREV_NET_DATA_SEND

- to be executed if message was sent to the network

Daniel-Constantin Mierla authored on 11/01/2016 11:39:59
Showing 2 changed files
... ...
@@ -170,6 +170,11 @@ int sr_event_register_cb(int type, sr_event_cb_f f)
170 170
 					_sr_events_list.tcp_closed = f;
171 171
 				else return -1;
172 172
 			break;
173
+		case SREV_NET_DATA_SEND:
174
+				if(_sr_events_list.net_data_send==0)
175
+					_sr_events_list.net_data_send = f;
176
+				else return -1;
177
+			break;
173 178
 		default:
174 179
 			return -1;
175 180
 	}
... ...
@@ -295,6 +300,12 @@ int sr_event_exec(int type, void *data)
295 300
 					ret = _sr_events_list.tcp_closed(data);
296 301
 					return ret;
297 302
 				} else return 1;
303
+		case SREV_NET_DATA_SEND:
304
+				if(unlikely(_sr_events_list.net_data_send!=0))
305
+				{
306
+					ret = _sr_events_list.net_data_send(data);
307
+					return ret;
308
+				} else return 1;
298 309
 		default:
299 310
 			return -1;
300 311
 	}
... ...
@@ -332,6 +343,8 @@ int sr_event_enabled(int type)
332 343
 				return (_sr_events_list.rcv_nosip!=0)?1:0;
333 344
 		case SREV_TCP_CLOSED:
334 345
 				return (_sr_events_list.tcp_closed!=0)?1:0;
346
+		case SREV_NET_DATA_SEND:
347
+				return (_sr_events_list.net_data_send!=0)?1:0;
335 348
 	}
336 349
 	return 0;
337 350
 }
... ...
@@ -35,6 +35,7 @@
35 35
 #define SREV_TCP_WS_FRAME_OUT		11
36 36
 #define SREV_STUN_IN			12
37 37
 #define SREV_TCP_CLOSED			13
38
+#define SREV_NET_DATA_SEND		14
38 39
 
39 40
 #define SREV_CB_LIST_SIZE	3
40 41
 
... ...
@@ -54,6 +55,7 @@ typedef struct sr_event_cb {
54 55
 	sr_event_cb_f stun_in;
55 56
 	sr_event_cb_f rcv_nosip;
56 57
 	sr_event_cb_f tcp_closed;
58
+	sr_event_cb_f net_data_send;
57 59
 } sr_event_cb_t;
58 60
 
59 61
 void sr_event_cb_init(void);