mirror of
https://github.com/asterisk/asterisk.git
synced 2026-06-10 04:26:14 +00:00
........
r420089 | mjordan | 2014-08-05 15:10:52 -0500 (Tue, 05 Aug 2014) | 72 lines
ARI: Add channel technology agnostic out of call text messaging
This patch adds the ability to send and receive text messages from various
technology stacks in Asterisk through ARI. This includes chan_sip (sip),
res_pjsip_messaging (pjsip), and res_xmpp (xmpp). Messages are sent using the
endpoints resource, and can be sent directly through that resource, or to a
particular endpoint.
For example, the following would send the message "Hello there" to PJSIP
endpoint alice with a display URI of sip:asterisk@mycooldomain.org:
ari/endpoints/sendMessage?to=pjsip:alice&from=sip:asterisk@mycooldomain.org&body=Hello+There
This is equivalent to the following as well:
ari/endpoints/PJSIP/alice/sendMessage?from=sip:asterisk@mycooldomain.org&body=Hello+There
Both forms are available for message technologies that allow for arbitrary
destinations, such as chan_sip.
Inbound messages can now be received over ARI as well. An ARI application that
subscribes to endpoints will receive messages from those endpoints:
{
"type": "TextMessageReceived",
"timestamp": "2014-07-12T22:53:13.494-0500",
"endpoint": {
"technology": "PJSIP",
"resource": "alice",
"state": "online",
"channel_ids": []
},
"message": {
"from": "\"alice\" <sip:alice@127.0.0.1>",
"to": "pjsip:asterisk@127.0.0.1",
"body": "Watson, come here.",
"variables": []
},
"application": "testsuite"
}
The above was made possible due to some rather major changes in the message
core. This includes (but is not limited to):
- Users of the message API can now register message handlers. A handler has
two callbacks: one to determine if the handler has a destination for the
message, and another to handle it.
- All dialplan functionality of handling a message was moved into a message
handler provided by the message API.
- Messages can now have the technology/endpoint associated with them.
Various other properties are also now more easily accessible.
- A number of ao2 containers that weren't really needed were replaced with
vectors. Iteration over ao2_containers is expensive and pointless when
the lifetime of things is well defined and the number of things is very
small.
res_stasis now has a new file that makes up its structure, messaging. The
messaging functionality implements a message handler, and passes received
messages that match an interested endpoint over to the app for processing.
Note that inadvertently while testing this, I reproduced ASTERISK-23969.
res_pjsip_messaging was incorrectly parsing out the 'to' field, such that
arbitrary SIP URIs mangled the endpoint lookup. This patch includes the
fix for that as well.
Review: https://reviewboard.asterisk.org/r/3726
ASTERISK-23692 #close
Reported by: Matt Jordan
ASTERISK-23969 #close
Reported by: Andrew Nagy
........
r420090 | mjordan | 2014-08-05 15:16:37 -0500 (Tue, 05 Aug 2014) | 2 lines
Remove automerge properties :-(
........
r420097 | mjordan | 2014-08-05 16:36:25 -0500 (Tue, 05 Aug 2014) | 2 lines
test_message: Fix strict-aliasing compilation issue
........
Merged revisions 420089-420090,420097 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@420098 65c4cc65-6c06-0410-ace0-fbb531ad65f3
692 lines
17 KiB
JSON
692 lines
17 KiB
JSON
{
|
|
"_copyright": "Copyright (C) 2012 - 2013, Digium, Inc.",
|
|
"_author": "David M. Lee, II <dlee@digium.com>",
|
|
"_svn_revision": "$Revision$",
|
|
"apiVersion": "1.4.0",
|
|
"swaggerVersion": "1.2",
|
|
"basePath": "http://localhost:8088/stasis",
|
|
"resourcePath": "/api-docs/events.{format}",
|
|
"apis": [
|
|
{
|
|
"path": "/events",
|
|
"description": "Events from Asterisk to applications",
|
|
"operations": [
|
|
{
|
|
"httpMethod": "GET",
|
|
"upgrade": "websocket",
|
|
"websocketProtocol": "ari",
|
|
"summary": "WebSocket connection for events.",
|
|
"nickname": "eventWebsocket",
|
|
"responseClass": "Message",
|
|
"parameters": [
|
|
{
|
|
"name": "app",
|
|
"description": "Applications to subscribe to.",
|
|
"paramType": "query",
|
|
"required": true,
|
|
"allowMultiple": true,
|
|
"dataType": "string"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"path": "/events/user/{eventName}",
|
|
"description": "Stasis application user events",
|
|
"operations": [
|
|
{
|
|
"httpMethod": "POST",
|
|
"summary": "Generate a user event.",
|
|
"nickname": "userEvent",
|
|
"responseClass": "void",
|
|
"parameters": [
|
|
{
|
|
"name": "eventName",
|
|
"description": "Event name",
|
|
"paramType": "path",
|
|
"required": true,
|
|
"allowMultiple": false,
|
|
"dataType": "string"
|
|
},
|
|
{
|
|
"name": "application",
|
|
"description": "The name of the application that will receive this event",
|
|
"paramType": "query",
|
|
"required": true,
|
|
"allowMultiple": false,
|
|
"dataType": "string"
|
|
},
|
|
{
|
|
"name": "source",
|
|
"description": "URI for event source (channel:{channelId}, bridge:{bridgeId}, endpoint:{tech}/{resource}, deviceState:{deviceName}",
|
|
"paramType": "query",
|
|
"required": false,
|
|
"allowMultiple": true,
|
|
"dataType": "string"
|
|
},
|
|
{
|
|
"name": "variables",
|
|
"description": "The \"variables\" key in the body object holds custom key/value pairs to add to the user event. Ex. { \"variables\": { \"key\": \"value\" } }",
|
|
"paramType": "body",
|
|
"required": false,
|
|
"allowMultiple": false,
|
|
"dataType": "containers"
|
|
}
|
|
],
|
|
"errorResponses": [
|
|
{
|
|
"code": 404,
|
|
"reason": "Application does not exist."
|
|
},
|
|
{
|
|
"code": 422,
|
|
"reason": "Event source not found."
|
|
},
|
|
{
|
|
"code": 400,
|
|
"reason": "Invalid even tsource URI or userevent data."
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"models": {
|
|
"Message": {
|
|
"id": "Message",
|
|
"description": "Base type for errors and events",
|
|
"discriminator": "type",
|
|
"properties": {
|
|
"type": {
|
|
"type": "string",
|
|
"required": true,
|
|
"description": "Indicates the type of this message."
|
|
}
|
|
},
|
|
"subTypes": [
|
|
"MissingParams",
|
|
"Event"
|
|
]
|
|
},
|
|
"MissingParams": {
|
|
"id": "MissingParams",
|
|
"description": "Error event sent when required params are missing.",
|
|
"properties": {
|
|
"params": {
|
|
"required": true,
|
|
"type": "List[string]",
|
|
"description": "A list of the missing parameters"
|
|
}
|
|
}
|
|
},
|
|
"Event": {
|
|
"id": "Event",
|
|
"description": "Base type for asynchronous events from Asterisk.",
|
|
"properties": {
|
|
"application": {
|
|
"type": "string",
|
|
"description": "Name of the application receiving the event.",
|
|
"required": true
|
|
},
|
|
"timestamp": {
|
|
"type": "Date",
|
|
"description": "Time at which this event was created.",
|
|
"required": false
|
|
}
|
|
},
|
|
"subTypes": [
|
|
"DeviceStateChanged",
|
|
"PlaybackStarted",
|
|
"PlaybackFinished",
|
|
"RecordingStarted",
|
|
"RecordingFinished",
|
|
"RecordingFailed",
|
|
"ApplicationReplaced",
|
|
"BridgeCreated",
|
|
"BridgeDestroyed",
|
|
"BridgeMerged",
|
|
"BridgeBlindTransfer",
|
|
"BridgeAttendedTransfer",
|
|
"ChannelCreated",
|
|
"ChannelDestroyed",
|
|
"ChannelEnteredBridge",
|
|
"ChannelLeftBridge",
|
|
"ChannelStateChange",
|
|
"ChannelDtmfReceived",
|
|
"ChannelDialplan",
|
|
"ChannelCallerId",
|
|
"ChannelUserevent",
|
|
"ChannelHangupRequest",
|
|
"ChannelVarset",
|
|
"ChannelTalkingStarted",
|
|
"ChannelTalkingFinished",
|
|
"EndpointStateChange",
|
|
"Dial",
|
|
"StasisEnd",
|
|
"StasisStart",
|
|
"TextMessageReceived"
|
|
]
|
|
},
|
|
"DeviceStateChanged": {
|
|
"id": "DeviceStateChanged",
|
|
"description": "Notification that a device state has changed.",
|
|
"properties": {
|
|
"device_state": {
|
|
"type": "DeviceState",
|
|
"description": "Device state object",
|
|
"required": true
|
|
}
|
|
}
|
|
},
|
|
"PlaybackStarted": {
|
|
"id": "PlaybackStarted",
|
|
"description": "Event showing the start of a media playback operation.",
|
|
"properties": {
|
|
"playback": {
|
|
"type": "Playback",
|
|
"description": "Playback control object",
|
|
"required": true
|
|
}
|
|
}
|
|
},
|
|
"PlaybackFinished": {
|
|
"id": "PlaybackFinished",
|
|
"description": "Event showing the completion of a media playback operation.",
|
|
"properties": {
|
|
"playback": {
|
|
"type": "Playback",
|
|
"description": "Playback control object",
|
|
"required": true
|
|
}
|
|
}
|
|
},
|
|
"RecordingStarted": {
|
|
"id": "RecordingStarted",
|
|
"extends": "Event",
|
|
"description": "Event showing the start of a recording operation.",
|
|
"properties": {
|
|
"recording": {
|
|
"type": "LiveRecording",
|
|
"description": "Recording control object",
|
|
"required": true
|
|
}
|
|
}
|
|
},
|
|
"RecordingFinished": {
|
|
"id": "RecordingFinished",
|
|
"extends": "Event",
|
|
"description": "Event showing the completion of a recording operation.",
|
|
"properties": {
|
|
"recording": {
|
|
"type": "LiveRecording",
|
|
"description": "Recording control object",
|
|
"required": true
|
|
}
|
|
}
|
|
},
|
|
"RecordingFailed": {
|
|
"id": "RecordingFailed",
|
|
"extends": "Event",
|
|
"description": "Event showing failure of a recording operation.",
|
|
"properties": {
|
|
"recording": {
|
|
"type": "LiveRecording",
|
|
"description": "Recording control object",
|
|
"required": true
|
|
}
|
|
}
|
|
},
|
|
"ApplicationReplaced": {
|
|
"id": "ApplicationReplaced",
|
|
"description": "Notification that another WebSocket has taken over for an application.\n\nAn application may only be subscribed to by a single WebSocket at a time. If multiple WebSockets attempt to subscribe to the same application, the newer WebSocket wins, and the older one receives this event.",
|
|
"properties": {}
|
|
},
|
|
"BridgeCreated": {
|
|
"id": "BridgeCreated",
|
|
"description": "Notification that a bridge has been created.",
|
|
"properties": {
|
|
"bridge": {
|
|
"required": true,
|
|
"type": "Bridge"
|
|
}
|
|
}
|
|
},
|
|
"BridgeDestroyed": {
|
|
"id": "BridgeDestroyed",
|
|
"description": "Notification that a bridge has been destroyed.",
|
|
"properties": {
|
|
"bridge": {
|
|
"required": true,
|
|
"type": "Bridge"
|
|
}
|
|
}
|
|
},
|
|
"BridgeMerged": {
|
|
"id": "BridgeMerged",
|
|
"description": "Notification that one bridge has merged into another.",
|
|
"properties": {
|
|
"bridge": {
|
|
"required": true,
|
|
"type": "Bridge"
|
|
},
|
|
"bridge_from": {
|
|
"required": true,
|
|
"type": "Bridge"
|
|
}
|
|
}
|
|
},
|
|
"BridgeBlindTransfer": {
|
|
"id": "BridgeBlindTransfer",
|
|
"description": "Notification that a blind transfer has occurred.",
|
|
"properties": {
|
|
"channel": {
|
|
"description": "The channel performing the blind transfer",
|
|
"required": true,
|
|
"type": "Channel"
|
|
},
|
|
"exten": {
|
|
"description": "The extension transferred to",
|
|
"required": true,
|
|
"type": "string"
|
|
},
|
|
"context": {
|
|
"description": "The context transferred to",
|
|
"required": true,
|
|
"type": "string"
|
|
},
|
|
"result": {
|
|
"description": "The result of the transfer attempt",
|
|
"required": true,
|
|
"type": "string"
|
|
},
|
|
"is_external": {
|
|
"description": "Whether the transfer was externally initiated or not",
|
|
"required": true,
|
|
"type": "boolean"
|
|
},
|
|
"bridge": {
|
|
"description": "The bridge being transferred",
|
|
"type": "Bridge"
|
|
}
|
|
}
|
|
},
|
|
"BridgeAttendedTransfer": {
|
|
"id": "BridgeAttendedTransfer",
|
|
"description": "Notification that an attended transfer has occurred.",
|
|
"properties": {
|
|
"transferer_first_leg": {
|
|
"description": "First leg of the transferer",
|
|
"required": true,
|
|
"type": "Channel"
|
|
},
|
|
"transferer_second_leg": {
|
|
"description": "Second leg of the transferer",
|
|
"required": true,
|
|
"type": "Channel"
|
|
},
|
|
"result": {
|
|
"description": "The result of the transfer attempt",
|
|
"required": true,
|
|
"type": "string"
|
|
},
|
|
"is_external": {
|
|
"description": "Whether the transfer was externally initiated or not",
|
|
"required": true,
|
|
"type": "boolean"
|
|
},
|
|
"transferer_first_leg_bridge": {
|
|
"description": "Bridge the transferer first leg is in",
|
|
"type": "Bridge"
|
|
},
|
|
"transferer_second_leg_bridge": {
|
|
"description": "Bridge the transferer second leg is in",
|
|
"type": "Bridge"
|
|
},
|
|
"destination_type": {
|
|
"description": "How the transfer was accomplished",
|
|
"required": true,
|
|
"type": "string"
|
|
},
|
|
"destination_bridge": {
|
|
"description": "Bridge that survived the merge result",
|
|
"type": "string"
|
|
},
|
|
"destination_application": {
|
|
"description": "Application that has been transferred into",
|
|
"type": "string"
|
|
},
|
|
"destination_link_first_leg": {
|
|
"description": "First leg of a link transfer result",
|
|
"type": "Channel"
|
|
},
|
|
"destination_link_second_leg": {
|
|
"description": "Second leg of a link transfer result",
|
|
"type": "Channel"
|
|
},
|
|
"destination_threeway_channel": {
|
|
"description": "Transferer channel that survived the threeway result",
|
|
"type": "Channel"
|
|
},
|
|
"destination_threeway_bridge": {
|
|
"description": "Bridge that survived the threeway result",
|
|
"type": "Bridge"
|
|
}
|
|
}
|
|
},
|
|
"ChannelCreated": {
|
|
"id": "ChannelCreated",
|
|
"description": "Notification that a channel has been created.",
|
|
"properties": {
|
|
"channel": {
|
|
"required": true,
|
|
"type": "Channel"
|
|
}
|
|
}
|
|
},
|
|
"ChannelDestroyed": {
|
|
"id": "ChannelDestroyed",
|
|
"description": "Notification that a channel has been destroyed.",
|
|
"properties": {
|
|
"cause": {
|
|
"required": true,
|
|
"description": "Integer representation of the cause of the hangup",
|
|
"type": "int"
|
|
},
|
|
"cause_txt": {
|
|
"required": true,
|
|
"description": "Text representation of the cause of the hangup",
|
|
"type": "string"
|
|
},
|
|
"channel": {
|
|
"required": true,
|
|
"type": "Channel"
|
|
}
|
|
}
|
|
},
|
|
"ChannelEnteredBridge": {
|
|
"id": "ChannelEnteredBridge",
|
|
"description": "Notification that a channel has entered a bridge.",
|
|
"properties": {
|
|
"bridge": {
|
|
"required": true,
|
|
"type": "Bridge"
|
|
},
|
|
"channel": {
|
|
"type": "Channel"
|
|
}
|
|
}
|
|
},
|
|
"ChannelLeftBridge": {
|
|
"id": "ChannelLeftBridge",
|
|
"description": "Notification that a channel has left a bridge.",
|
|
"properties": {
|
|
"bridge": {
|
|
"required": true,
|
|
"type": "Bridge"
|
|
},
|
|
"channel": {
|
|
"required": true,
|
|
"type": "Channel"
|
|
}
|
|
}
|
|
},
|
|
"ChannelStateChange": {
|
|
"id": "ChannelStateChange",
|
|
"description": "Notification of a channel's state change.",
|
|
"properties": {
|
|
"channel": {
|
|
"required": true,
|
|
"type": "Channel"
|
|
}
|
|
}
|
|
},
|
|
"ChannelDtmfReceived": {
|
|
"id": "ChannelDtmfReceived",
|
|
"description": "DTMF received on a channel.\n\nThis event is sent when the DTMF ends. There is no notification about the start of DTMF",
|
|
"properties": {
|
|
"digit": {
|
|
"required": true,
|
|
"type": "string",
|
|
"description": "DTMF digit received (0-9, A-E, # or *)"
|
|
},
|
|
"duration_ms": {
|
|
"required": true,
|
|
"type": "int",
|
|
"description": "Number of milliseconds DTMF was received"
|
|
},
|
|
"channel": {
|
|
"required": true,
|
|
"type": "Channel",
|
|
"description": "The channel on which DTMF was received"
|
|
}
|
|
}
|
|
},
|
|
"ChannelDialplan": {
|
|
"id": "ChannelDialplan",
|
|
"description": "Channel changed location in the dialplan.",
|
|
"properties": {
|
|
"channel": {
|
|
"required": true,
|
|
"type": "Channel",
|
|
"description": "The channel that changed dialplan location."
|
|
},
|
|
"dialplan_app": {
|
|
"required": true,
|
|
"type": "string",
|
|
"description": "The application about to be executed."
|
|
},
|
|
"dialplan_app_data": {
|
|
"required": true,
|
|
"type": "string",
|
|
"description": "The data to be passed to the application."
|
|
}
|
|
}
|
|
},
|
|
"ChannelCallerId": {
|
|
"id": "ChannelCallerId",
|
|
"description": "Channel changed Caller ID.",
|
|
"properties": {
|
|
"caller_presentation": {
|
|
"required": true,
|
|
"type": "int",
|
|
"description": "The integer representation of the Caller Presentation value."
|
|
},
|
|
"caller_presentation_txt": {
|
|
"required": true,
|
|
"type": "string",
|
|
"description": "The text representation of the Caller Presentation value."
|
|
},
|
|
"channel": {
|
|
"required": true,
|
|
"type": "Channel",
|
|
"description": "The channel that changed Caller ID."
|
|
}
|
|
}
|
|
},
|
|
"ChannelUserevent": {
|
|
"id": "ChannelUserevent",
|
|
"description": "User-generated event with additional user-defined fields in the object.",
|
|
"properties": {
|
|
"eventname": {
|
|
"required": true,
|
|
"type": "string",
|
|
"description": "The name of the user event."
|
|
},
|
|
"channel": {
|
|
"required": false,
|
|
"type": "Channel",
|
|
"description": "A channel that is signaled with the user event."
|
|
},
|
|
"bridge": {
|
|
"required": false,
|
|
"type": "Bridge",
|
|
"description": "A bridge that is signaled with the user event."
|
|
},
|
|
"endpoint": {
|
|
"required": false,
|
|
"type": "Endpoint",
|
|
"description": "A endpoint that is signaled with the user event."
|
|
},
|
|
"userevent": {
|
|
"required": true,
|
|
"type": "object",
|
|
"description": "Custom Userevent data"
|
|
}
|
|
}
|
|
},
|
|
"ChannelHangupRequest": {
|
|
"id": "ChannelHangupRequest",
|
|
"description": "A hangup was requested on the channel.",
|
|
"properties": {
|
|
"cause": {
|
|
"type": "int",
|
|
"description": "Integer representation of the cause of the hangup."
|
|
},
|
|
"soft": {
|
|
"type": "boolean",
|
|
"description": "Whether the hangup request was a soft hangup request."
|
|
},
|
|
"channel": {
|
|
"required": true,
|
|
"type": "Channel",
|
|
"description": "The channel on which the hangup was requested."
|
|
}
|
|
}
|
|
},
|
|
"ChannelVarset": {
|
|
"id": "ChannelVarset",
|
|
"description": "Channel variable changed.",
|
|
"properties": {
|
|
"variable": {
|
|
"required": true,
|
|
"type": "string",
|
|
"description": "The variable that changed."
|
|
},
|
|
"value": {
|
|
"required": true,
|
|
"type": "string",
|
|
"description": "The new value of the variable."
|
|
},
|
|
"channel": {
|
|
"required": false,
|
|
"type": "Channel",
|
|
"description": "The channel on which the variable was set.\n\nIf missing, the variable is a global variable."
|
|
}
|
|
}
|
|
},
|
|
"ChannelTalkingStarted": {
|
|
"id": "ChannelTalkingStarted",
|
|
"description": "Talking was detected on the channel.",
|
|
"properties": {
|
|
"channel": {
|
|
"required": true,
|
|
"type": "Channel",
|
|
"description": "The channel on which talking started."
|
|
}
|
|
}
|
|
},
|
|
"ChannelTalkingFinished": {
|
|
"id": "ChannelTalkingFinished",
|
|
"description": "Talking is no longer detected on the channel.",
|
|
"properties": {
|
|
"channel": {
|
|
"required": true,
|
|
"type": "Channel",
|
|
"description": "The channel on which talking completed."
|
|
},
|
|
"duration": {
|
|
"required": true,
|
|
"type": "int",
|
|
"description": "The length of time, in milliseconds, that talking was detected on the channel"
|
|
}
|
|
}
|
|
},
|
|
"EndpointStateChange": {
|
|
"id": "EndpointStateChange",
|
|
"description": "Endpoint state changed.",
|
|
"properties": {
|
|
"endpoint": {
|
|
"required": true,
|
|
"type": "Endpoint"
|
|
}
|
|
}
|
|
},
|
|
"Dial": {
|
|
"id": "Dial",
|
|
"description": "Dialing state has changed.",
|
|
"properties": {
|
|
"caller": {
|
|
"required": false,
|
|
"type": "Channel",
|
|
"description": "The calling channel."
|
|
},
|
|
"peer": {
|
|
"required": true,
|
|
"type": "Channel",
|
|
"description": "The dialed channel."
|
|
},
|
|
"forward": {
|
|
"required": false,
|
|
"type": "string",
|
|
"description": "Forwarding target requested by the original dialed channel."
|
|
},
|
|
"forwarded": {
|
|
"required": false,
|
|
"type": "Channel",
|
|
"description": "Channel that the caller has been forwarded to."
|
|
},
|
|
"dialstring": {
|
|
"required": false,
|
|
"type": "string",
|
|
"description": "The dial string for calling the peer channel."
|
|
},
|
|
"dialstatus": {
|
|
"required": true,
|
|
"type": "string",
|
|
"description": "Current status of the dialing attempt to the peer."
|
|
}
|
|
}
|
|
},
|
|
"StasisEnd": {
|
|
"id": "StasisEnd",
|
|
"description": "Notification that a channel has left a Stasis application.",
|
|
"properties": {
|
|
"channel": {
|
|
"required": true,
|
|
"type": "Channel"
|
|
}
|
|
}
|
|
},
|
|
"StasisStart": {
|
|
"id": "StasisStart",
|
|
"description": "Notification that a channel has entered a Stasis application.",
|
|
"properties": {
|
|
"args": {
|
|
"required": true,
|
|
"type": "List[string]",
|
|
"description": "Arguments to the application"
|
|
},
|
|
"channel": {
|
|
"required": true,
|
|
"type": "Channel"
|
|
}
|
|
}
|
|
},
|
|
"TextMessageReceived": {
|
|
"id": "TextMessageReceived",
|
|
"description": "A text message was received from an endpoint.",
|
|
"properties": {
|
|
"message": {
|
|
"required": true,
|
|
"type": "TextMessage"
|
|
},
|
|
"endpoint": {
|
|
"required": false,
|
|
"type": "Endpoint"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|