[svn-commits] mmichelson: branch mmichelson/subscription_abstraction r416579 - /team/mmiche...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Jun 18 11:46:50 CDT 2014


Author: mmichelson
Date: Wed Jun 18 11:46:45 2014
New Revision: 416579

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=416579
Log:
Send a SUBSCRIBE when creating a subscriber-side subscription.


Modified:
    team/mmichelson/subscription_abstraction/res/res_pjsip_pubsub.c

Modified: team/mmichelson/subscription_abstraction/res/res_pjsip_pubsub.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/subscription_abstraction/res/res_pjsip_pubsub.c?view=diff&rev=416579&r1=416578&r2=416579
==============================================================================
--- team/mmichelson/subscription_abstraction/res/res_pjsip_pubsub.c (original)
+++ team/mmichelson/subscription_abstraction/res/res_pjsip_pubsub.c Wed Jun 18 11:46:45 2014
@@ -848,6 +848,8 @@
 	pjsip_dialog *dlg;
 	struct ast_sip_contact *contact;
 	pj_str_t event;
+	pjsip_tx_data *tdata;
+	pjsip_evsub *evsub;
 
 	sub = allocate_subscription(handler, endpoint, resource, AST_SIP_SUBSCRIBER);
 	if (!sub) {
@@ -862,6 +864,7 @@
 		ao2_cleanup(contact);
 		return NULL;
 	}
+
 	dlg = ast_sip_create_dialog_uac(endpoint, contact->uri, NULL);
 	ao2_cleanup(contact);
 	if (!dlg) {
@@ -876,7 +879,19 @@
 
 	add_subscription(sub);
 
-	/* XXX TODO We need to send our initial subscribe here */
+	evsub = sip_subscription_get_evsub(sub);
+
+	if (pjsip_evsub_initiate(evsub, NULL, -1, &tdata) == PJ_SUCCESS) {
+		pjsip_evsub_send_request(evsub, tdata);
+	} else {
+		/* pjsip_evsub_terminate will result in pubsub_on_evsub_state,
+		 * being called and terminating the subscription. Therefore, we don't
+		 * need to decrease the reference count of sub here.
+		 */
+		pjsip_evsub_terminate(evsub, PJ_TRUE);
+		return NULL;
+	}
+
 	return sub;
 }
 
@@ -1815,6 +1830,7 @@
 		pjsip_evsub_send_request(evsub, tdata);
 	} else {
 		pjsip_evsub_terminate(evsub, PJ_TRUE);
+		return 0;
 	}
 	ao2_cleanup(sub);
 	return 0;




More information about the svn-commits mailing list