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 295
 					ret = _sr_events_list.tcp_closed(data);
296 296
 					return ret;
297 297
 				} else return 1;
298
+		case SREV_NET_DATA_SEND:
299
+				if(unlikely(_sr_events_list.net_data_send!=0))
300
+				{
301
+					ret = _sr_events_list.net_data_send(data);
302
+					return ret;
303
+				} else return 1;
298 304
 		default:
299 305
 			return -1;
300 306
 	}
... ...
@@ -332,6 +343,8 @@ int sr_event_enabled(int type)
332 332
 				return (_sr_events_list.rcv_nosip!=0)?1:0;
333 333
 		case SREV_TCP_CLOSED:
334 334
 				return (_sr_events_list.tcp_closed!=0)?1:0;
335
+		case SREV_NET_DATA_SEND:
336
+				return (_sr_events_list.net_data_send!=0)?1:0;
335 337
 	}
336 338
 	return 0;
337 339
 }
... ...
@@ -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 54
 	sr_event_cb_f stun_in;
55 55
 	sr_event_cb_f rcv_nosip;
56 56
 	sr_event_cb_f tcp_closed;
57
+	sr_event_cb_f net_data_send;
57 58
 } sr_event_cb_t;
58 59
 
59 60
 void sr_event_cb_init(void);