]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_pjsip/AMI: add contact.updated event 55/2755/1
authorAlexei Gradinari <alex2grad@gmail.com>
Thu, 7 Apr 2016 21:33:49 +0000 (17:33 -0400)
committerAlexei Gradinari <alex2grad@gmail.com>
Tue, 3 May 2016 21:38:30 +0000 (16:38 -0500)
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

CHANGES
include/asterisk/res_pjsip.h
res/res_pjsip/pjsip_options.c

diff --git a/CHANGES b/CHANGES
index 9f067bd9f7f596f864ba9f71bfc24cee7f3b1cc4..8d1e339d6144888df170f8f5f84ffde81429d6d0 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -277,6 +277,8 @@ Queue
 
 res_pjsip
 ------------------
+ * Added new status Updated to AMI event ContactStatus on update registration
+
  * Added "reg_server" to contacts.
    If the Asterisk system name is set in asterisk.conf, it will be stored
    into the "reg_server" field in the ps_contacts table to facilitate
index b6684ae56f91710fc736ba6e5ab542fe45634ced..05f8100cf54b9fcc9b05a269bfd2867de612302b 100644 (file)
@@ -263,6 +263,7 @@ enum ast_sip_contact_status_type {
        UNKNOWN,
        CREATED,
        REMOVED,
+       UPDATED,
 };
 
 /*!
index fc64947edc7441b33a0676c70d6bee5bf8242230..c0d41c3d190f0c5790e6740224c7c948abd8f693 100644 (file)
@@ -42,6 +42,7 @@ static const char *status_map [] = {
        [UNKNOWN] = "Unknown",
        [CREATED] = "Created",
        [REMOVED] = "Removed",
+       [UPDATED] = "Updated",
 };
 
 static const char *short_status_map [] = {
@@ -50,6 +51,7 @@ static const char *short_status_map [] = {
        [UNKNOWN] = "Unknown",
        [CREATED] = "Created",
        [REMOVED] = "Removed",
+       [UPDATED] = "Updated",
 };
 
 const char *ast_sip_get_contact_status_label(const enum ast_sip_contact_status_type status)
@@ -530,6 +532,16 @@ static void contact_created(const void *obj)
        qualify_and_schedule((struct ast_sip_contact *) obj);
 }
 
+/*!
+ * \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.
@@ -556,7 +568,8 @@ static void contact_deleted(const void *obj)
 
 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)