[svn-commits] kmoore: branch kmoore/channel_event_refactor r391431 - in /team/kmoore/channe...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Jun 11 14:48:19 CDT 2013


Author: kmoore
Date: Tue Jun 11 14:48:17 2013
New Revision: 391431

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=391431
Log:
Refactor SIPQualifyPeer and add documentation for SessionTimeout

Modified:
    team/kmoore/channel_event_refactor/CHANGES
    team/kmoore/channel_event_refactor/channels/chan_sip.c

Modified: team/kmoore/channel_event_refactor/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/channel_event_refactor/CHANGES?view=diff&rev=391431&r1=391430&r2=391431
==============================================================================
--- team/kmoore/channel_event_refactor/CHANGES (original)
+++ team/kmoore/channel_event_refactor/CHANGES Tue Jun 11 14:48:17 2013
@@ -19,7 +19,7 @@
 
  * The SIPqualifypeer action now acknowledges the request once it has established
    that the request is against a known peer. It also issues a new event,
-   'SIPqualifypeerdone', once the qualify action has been completed.
+   'SIPQualifyPeerDone', once the qualify action has been completed.
 
  * The PlayDTMF action now supports an optional 'Duration' parameter.  This
    specifies the duration of the digit to be played, in milliseconds.

Modified: team/kmoore/channel_event_refactor/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/channel_event_refactor/channels/chan_sip.c?view=diff&rev=391431&r1=391430&r2=391431
==============================================================================
--- team/kmoore/channel_event_refactor/channels/chan_sip.c (original)
+++ team/kmoore/channel_event_refactor/channels/chan_sip.c Tue Jun 11 14:48:17 2013
@@ -565,7 +565,7 @@
 			<para>Qualify a SIP peer.</para>
 		</description>
 		<see-also>
-			<ref type="managerEvent">SIPqualifypeerdone</ref>
+			<ref type="managerEvent">SIPQualifyPeerDone</ref>
 		</see-also>
 	</manager>
 	<manager name="SIPshowregistry" language="en_US">
@@ -623,6 +623,33 @@
 		<para>Specifying a prefix of <literal>sip:</literal> will send the
 		message as a SIP MESSAGE request.</para>
 	</info>
+	<managerEvent language="en_US" name="SIPQualifyPeerDone">
+		<managerEventInstance class="EVENT_FLAG_CALL">
+			<synopsis>Raised when SIPQualifyPeer has finished qualifying the specified peer.</synopsis>
+			<syntax>
+				<parameter name="Peer">
+					<para>The name of the peer.</para>
+				</parameter>
+				<parameter name="ActionID">
+					<para>This is only included if an ActionID Header was sent with the action request, in which case it will be that ActionID.</para>
+				</parameter>
+			</syntax>
+			<see-also>
+				<ref type="manager">SIPqualifypeer</ref>
+			</see-also>
+		</managerEventInstance>
+	</managerEvent>
+	<managerEvent language="en_US" name="SessionTimeout">
+		<managerEventInstance class="EVENT_FLAG_CALL">
+			<synopsis>Raised when a SIP session times out.</synopsis>
+			<syntax>
+				<xi:include xpointer="xpointer(/docs/managerEvent[@name='Newchannel']/managerEventInstance/syntax/parameter)" />
+				<parameter name="Source">
+					<para>The source of the session timeout.</para>
+				</parameter>
+			</syntax>
+		</managerEventInstance>
+	</managerEvent>
  ***/
 
 static int min_expiry = DEFAULT_MIN_EXPIRY;        /*!< Minimum accepted registration time */
@@ -20033,6 +20060,43 @@
 	return 0;
 }
 
+static void publish_qualify_peer_done(const char *id, const char *peer)
+{
+	RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_json_payload *, payload, NULL, ao2_cleanup);
+	RAII_VAR(struct ast_json *, json_object, NULL, ast_json_unref);
+
+	if (ast_strlen_zero(id)) {
+		json_object = ast_json_pack("{s: s, s: i, s: {s: s}}",
+			"type", "SIPQualifyPeerDone",
+			"class_type", EVENT_FLAG_CALL,
+			"event",
+				"Peer", peer);
+	} else {
+		json_object = ast_json_pack("{s: s, s: i, s: {s: s, s: s}}",
+			"type", "SIPQualifyPeerDone",
+			"class_type", EVENT_FLAG_CALL,
+			"event",
+				"ActionID", id,
+				"Peer", peer);
+	}
+
+	if (!json_object) {
+		return;
+	}
+
+	payload = ast_json_payload_create(json_object);
+	if (!payload) {
+		return;
+	}
+
+	message = stasis_message_create(ast_manager_get_generic_type(), payload);
+	if (!message) {
+		return;
+	}
+
+	stasis_publish(ast_manager_get_topic(), message);
+}
 
 /*! \brief Send qualify message to peer from cli or manager. Mostly for debugging. */
 static char *_sip_qualify_peer(int type, int fd, struct mansession *s, const struct message *m, int argc, const char *argv[])
@@ -20045,41 +20109,15 @@
 
 	load_realtime = (argc == 5 && !strcmp(argv[4], "load")) ? TRUE : FALSE;
 	if ((peer = sip_find_peer(argv[3], NULL, load_realtime, FINDPEERS, FALSE, 0))) {
-
 		const char *id = astman_get_header(m,"ActionID");
-		char idText[256] = "";
 
 		if (type != 0) {
 			astman_send_ack(s, m, "SIP peer found - will qualify");
 		}
 
-		if (!ast_strlen_zero(id)) {
-			snprintf(idText, sizeof(idText), "ActionID: %s\r\n", id);
-		}
-
 		sip_poke_peer(peer, 1);
 
-		/*** DOCUMENTATION
-			<managerEventInstance>
-				<synopsis>Raised when SIPqualifypeer has finished qualifying the specified peer.</synopsis>
-				<syntax>
-					<parameter name="Peer">
-						<para>The name of the peer.</para>
-					</parameter>
-					<parameter name="ActionID">
-						<para>This is only included if an ActionID Header was sent with the action request, in which case it will be that ActionID.</para>
-					</parameter>
-				</syntax>
-				<see-also>
-					<ref type="manager">SIPqualifypeer</ref>
-				</see-also>
-			</managerEventInstance>
-		***/
-		manager_event(EVENT_FLAG_CALL, "SIPqualifypeerdone",
-			"Peer: %s\r\n"
-			"%s",
-			argv[3],
-			idText);
+		publish_qualify_peer_done(id, argv[3]);
 
 		sip_unref_peer(peer, "qualify: done with peer");
 	} else if (type == 0) {




More information about the svn-commits mailing list