[Asterisk-code-review] res pjsip/AMI: add contact.updated event (asterisk[13])

Alexei Gradinari asteriskteam at digium.com
Thu Apr 7 16:37:21 CDT 2016


Alexei Gradinari has uploaded a new change for review.

  https://gerrit.asterisk.org/2556

Change subject: res_pjsip/AMI: add contact.updated event
......................................................................

res_pjsip/AMI: add contact.updated event

With the old SIP module AMI sends PeerStatus event on every
successfully REGISTER requests, ie, on start registration,
update registration and stop registration.

With PJSIP AMI sends ContactStatus only when status is changed.
Regarding registration:
on start registration - Created
on stop registration - Removed
but on update registration nothing

This patch added contact.updated event.

ASTERISK-25904

Change-Id: I8fad8aae9305481469c38d2146e1ba3a56d3108f
---
M include/asterisk/res_pjsip.h
M res/res_pjsip/pjsip_options.c
2 files changed, 15 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/56/2556/1

diff --git a/include/asterisk/res_pjsip.h b/include/asterisk/res_pjsip.h
index fbb9bdc..39e7ebb 100644
--- a/include/asterisk/res_pjsip.h
+++ b/include/asterisk/res_pjsip.h
@@ -254,6 +254,7 @@
 	UNKNOWN,
 	CREATED,
 	REMOVED,
+	UPDATED,
 };
 
 /*!
diff --git a/res/res_pjsip/pjsip_options.c b/res/res_pjsip/pjsip_options.c
index 3a45243..3c5e26a 100644
--- a/res/res_pjsip/pjsip_options.c
+++ b/res/res_pjsip/pjsip_options.c
@@ -42,6 +42,7 @@
 	[UNKNOWN] = "Unknown",
 	[CREATED] = "Created",
 	[REMOVED] = "Removed",
+	[UPDATED] = "Updated",
 };
 
 static const char *short_status_map [] = {
@@ -50,6 +51,7 @@
 	[UNKNOWN] = "Unknown",
 	[CREATED] = "Created",
 	[REMOVED] = "Removed",
+	[UPDATED] = "Updated",
 };
 
 const char *ast_sip_get_contact_status_label(const enum ast_sip_contact_status_type status)
@@ -543,6 +545,16 @@
 
 /*!
  * \internal
+ * \brief A contact has been updated.
+ */
+static void contact_updated(const void *obj)
+{
+	update_contact_status((struct ast_sip_contact *) obj, UPDATED);
+	qualify_and_schedule((struct ast_sip_contact *) obj);
+}
+
+/*!
+ * \internal
  * \brief A contact has been deleted remove status tracking.
  */
 static void contact_deleted(const void *obj)
@@ -567,7 +579,8 @@
 
 static const struct ast_sorcery_observer contact_observer = {
 	.created = contact_created,
-	.deleted = contact_deleted
+	.deleted = contact_deleted,
+	.updated = contact_updated
 };
 
 static pj_bool_t options_start(void)

-- 
To view, visit https://gerrit.asterisk.org/2556
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8fad8aae9305481469c38d2146e1ba3a56d3108f
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Alexei Gradinari <alex2grad at gmail.com>



More information about the asterisk-code-review mailing list