[asterisk-commits] mmichelson: branch mmichelson/pub_sub r385118 - /team/mmichelson/pub_sub/res/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Apr 9 13:31:20 CDT 2013


Author: mmichelson
Date: Tue Apr  9 13:31:17 2013
New Revision: 385118

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=385118
Log:
Set up serialization for subscriptions.


Modified:
    team/mmichelson/pub_sub/res/res_sip_pubsub.c

Modified: team/mmichelson/pub_sub/res/res_sip_pubsub.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/pub_sub/res/res_sip_pubsub.c?view=diff&rev=385118&r1=385117&r2=385118
==============================================================================
--- team/mmichelson/pub_sub/res/res_sip_pubsub.c (original)
+++ team/mmichelson/pub_sub/res/res_sip_pubsub.c Tue Apr  9 13:31:17 2013
@@ -104,16 +104,14 @@
 };
 
 static pjsip_evsub *allocate_evsub(const char *event, enum ast_sip_subscription_role role,
-		struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata)
-{
-	pjsip_dialog *dlg;
+		struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, pjsip_dialog *dlg)
+{
 	pjsip_evsub *evsub;
 	/* PJSIP is kind enough to have some built-in support for certain
 	 * events. We need to use the correct initialization function for the
 	 * built-in events
 	 */
 	if (role == AST_SIP_NOTIFIER) {
-		pjsip_dlg_create_uas(pjsip_ua_instance(), rdata, NULL, &dlg);
 		if (!strcmp(event, "message-summary")) {
 			pjsip_mwi_create_uas(dlg, &pubsub_cb, rdata, &evsub);
 		} else if (!strcmp(event, "presence")) {
@@ -122,7 +120,6 @@
 			pjsip_evsub_create_uas(dlg, &pubsub_cb, rdata, 0, &evsub);
 		}
 	} else {
-		dlg = ast_sip_create_dialog(endpoint, NULL, NULL);
 		if (!strcmp(event, "message-summary")) {
 			pjsip_mwi_create_uac(dlg, &pubsub_cb, 0, &evsub);
 		} else if (!strcmp(event, "presence")) {
@@ -140,6 +137,7 @@
         enum ast_sip_subscription_role role, struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata)
 {
 	struct ast_sip_subscription *sub = ao2_alloc(sizeof(*sub), subscription_destructor);
+	pjsip_dialog *dlg;
 
 	if (!sub) {
 		return NULL;
@@ -154,7 +152,14 @@
 		ao2_ref(sub, -1);
 		return NULL;
 	}
-	sub->evsub = allocate_evsub(handler->event_name, role, endpoint, rdata);
+	sub->role = role;
+	if (role == AST_SIP_NOTIFIER) {
+		pjsip_dlg_create_uas(pjsip_ua_instance(), rdata, NULL, &dlg);
+	} else {
+		dlg = ast_sip_create_dialog(endpoint, NULL, NULL);
+	}
+	ast_sip_dialog_set_serializer(dlg, sub->serializer);
+	sub->evsub = allocate_evsub(handler->event_name, role, endpoint, rdata, dlg);
 	pjsip_evsub_set_mod_data(sub->evsub, sub_module.id, sub);
 	ao2_ref(endpoint, +1);
 	sub->endpoint = endpoint;
@@ -395,7 +400,7 @@
 
 static void pubsub_on_tsx_state(pjsip_evsub *evsub, pjsip_transaction *tsx, pjsip_event *event)
 {
-	struct ast_sip_subscription *sub= pjsip_evsub_get_mod_data(evsub, sub_module.id);
+	struct ast_sip_subscription *sub = pjsip_evsub_get_mod_data(evsub, sub_module.id);
 
 	if (!sub) {
 		return;
@@ -447,7 +452,7 @@
 static void pubsub_on_rx_refresh(pjsip_evsub *evsub, pjsip_rx_data *rdata,
 		int *p_st_code, pj_str_t **p_st_text, pjsip_hdr *res_hdr, pjsip_msg_body **p_body)
 {
-	struct ast_sip_subscription *sub= pjsip_evsub_get_mod_data(evsub, sub_module.id);
+	struct ast_sip_subscription *sub = pjsip_evsub_get_mod_data(evsub, sub_module.id);
 	struct ast_sip_subscription_response_data *response_data;
 
 	if (!sub) {
@@ -467,7 +472,7 @@
 static void pubsub_on_rx_notify(pjsip_evsub *evsub, pjsip_rx_data *rdata, int *p_st_code,
 		pj_str_t **p_st_text, pjsip_hdr *res_hdr, pjsip_msg_body **p_body)
 {
-	struct ast_sip_subscription *sub= pjsip_evsub_get_mod_data(evsub, sub_module.id);
+	struct ast_sip_subscription *sub = pjsip_evsub_get_mod_data(evsub, sub_module.id);
 	struct ast_sip_subscription_response_data *response_data;
 
 	if (!sub|| !sub->handler->notify_request) {
@@ -486,7 +491,7 @@
 
 static void pubsub_on_client_refresh(pjsip_evsub *evsub)
 {
-	struct ast_sip_subscription *sub= pjsip_evsub_get_mod_data(evsub, sub_module.id);
+	struct ast_sip_subscription *sub = pjsip_evsub_get_mod_data(evsub, sub_module.id);
 
 	sub->handler->refresh_subscription(sub);
 }




More information about the asterisk-commits mailing list