[asterisk-commits] dlee: branch dlee/stasis-http r384385 - in /team/dlee/stasis-http: res/stasis...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Mar 29 20:35:25 CDT 2013


Author: dlee
Date: Fri Mar 29 20:35:22 2013
New Revision: 384385

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=384385
Log:
Documenting WebSocket events

Modified:
    team/dlee/stasis-http/res/stasis_http/resource_events.h
    team/dlee/stasis-http/res/stasis_http/resources.c
    team/dlee/stasis-http/rest-api/events.json

Modified: team/dlee/stasis-http/res/stasis_http/resource_events.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/res/stasis_http/resource_events.h?view=diff&rev=384385&r1=384384&r2=384385
==============================================================================
--- team/dlee/stasis-http/res/stasis_http/resource_events.h (original)
+++ team/dlee/stasis-http/res/stasis_http/resource_events.h Fri Mar 29 20:35:22 2013
@@ -35,6 +35,8 @@
 #ifndef _ASTERISK_RESOURCE_EVENTS_H
 #define _ASTERISK_RESOURCE_EVENTS_H
 struct ast_event_websocket_args {
+	/*! Comma seperated list of applications to subscribe to. */
+	const char *app;
 };
 /*!
  * \brief WebSocket connection for events.

Modified: team/dlee/stasis-http/res/stasis_http/resources.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/res/stasis_http/resources.c?view=diff&rev=384385&r1=384384&r2=384385
==============================================================================
--- team/dlee/stasis-http/res/stasis_http/resources.c (original)
+++ team/dlee/stasis-http/res/stasis_http/resources.c Fri Mar 29 20:35:22 2013
@@ -477,8 +477,14 @@
 
 static void stasis_http_event_websocket_cb(struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct stasis_http_response *response)
 {
+	struct ast_variable *i;
 	struct ast_event_websocket_args args = {};
 
+	for (i = get_params; i; i = i->next) {
+		if (strcmp(i->name, "app") == 0) {
+			args.app = i->value;
+		}
+	}
 	stasis_http_event_websocket(headers, &args, response);
 }
 

Modified: team/dlee/stasis-http/rest-api/events.json
URL: http://svnview.digium.com/svn/asterisk/team/dlee/stasis-http/rest-api/events.json?view=diff&rev=384385&r1=384384&r2=384385
==============================================================================
--- team/dlee/stasis-http/rest-api/events.json (original)
+++ team/dlee/stasis-http/rest-api/events.json Fri Mar 29 20:35:22 2013
@@ -10,85 +10,77 @@
         {
             "path": "/api/events",
             "description": "Events from Asterisk to applications",
-	    "operations": [
-		{
-		    "httpMethod": "GET",
-		    "summary": "WebSocket connection for events",
-		    "nickname": "event_websocket",
-		    "responseClass": "Event"
-		}
-	    ]
+            "operations": [
+                {
+                    "httpMethod": "GET",
+                    "summary": "WebSocket connection for events",
+                    "nickname": "event_websocket",
+                    "responseClass": "Event",
+		    "parameters": [
+			{
+			    "name": "app",
+			    "description": "Comma seperated list of applications to subscribe to.",
+			    "paramType": "query",
+			    "required": true,
+			    "allowMultiple": true,
+			    "dataType": "string"
+			}
+		    ]
+                }
+            ]
         }
     ],
     "models": {
-	"Event": {
-	    "id": "Event",
-	    "properties": {
-		"application": {
-		    "type": "string",
-		    "description": "Name of the application receiving the event",
-		    "required": true
-		},
-		"event": {
-		    "type": "string",
-		    "description": "Event name.",
-		    "required": true,
-		    "allowableValues": {
-			"valueType": "LIST",
-			"values": [
-			    "stasis-start",
-			    "stasis-end",
-			    "channel-state-change",
-			    "application-replaced"
-			]
-		    }
-		},
-		"event_info": {
-		    "type": "object",
-		    "oneOf": [
-			{ "$ref": "StasisStart" },
-			{ "$ref": "StasisEnd" },
-			{ "$ref": "ChannelStateChange" },
-			{ "$ref": "ApplicationReplaced" }
-		    ]
-		}
-	    }
-	},
-	"StasisStart": {
-	    "id": "StasisStart",
-	    "properties": {
-		"args": {
-		    "type": "LIST",
-		    "description": "Arguments to the application",
-		    "items": {
-			"$ref": "string"
-		    }
-		},
-		"channel_info": {
-		    "type": "Channel"
-		}
-	    }
-	},
-	"StasisEnd": {
-	    "id": "StasisEnd",
-	    "properties": {
-		"channel_info": {
-		    "type": "Channel"
-		}
-	    }
-	},
-	"ChannelStateChange": {
-	    "id": "ChannelStateChange",
-	    "properties": {
-		"channel_info": {
-		    "type": "Channel"
-		}
-	    }
-	},
-	"ApplicationReplaced": {
-	    "id": "ApplicationReplaced",
-	    "properties": {
-	    }
-	}
+        "Event": {
+            "id": "Event",
+	    "description": "Asynchronous events from Asterisk. The non-required fields of this object are mutually exclusive.",
+            "properties": {
+                "application": {
+                    "type": "string",
+                    "description": "Name of the application receiving the event",
+                    "required": true
+                },
+                "stasis-start": { "type": "StasisStart" },
+                "stasis-end": { "type": "StasisEnd" },
+                "channel-state-change": { "type": "ChannelStateChange" },
+                "application-replaced": { "type": "ApplicationReplaced" }
+            }
+        },
+        "StasisStart": {
+            "id": "StasisStart",
+            "properties": {
+                "args": {
+                    "type": "LIST",
+                    "description": "Arguments to the application",
+                    "items": {
+                        "$ref": "string"
+                    }
+                },
+                "channel_info": {
+                    "type": "Channel"
+                }
+            }
+        },
+        "StasisEnd": {
+            "id": "StasisEnd",
+            "properties": {
+                "channel_info": {
+                    "type": "Channel"
+                }
+            }
+        },
+        "ChannelStateChange": {
+            "id": "ChannelStateChange",
+            "properties": {
+                "channel_info": {
+                    "type": "Channel"
+                }
+            }
+        },
+        "ApplicationReplaced": {
+            "id": "ApplicationReplaced",
+            "properties": {
+            }
+        }
     }
 }




More information about the asterisk-commits mailing list