-
Notifications
You must be signed in to change notification settings - Fork 34
FreeSWITCH Rayo Extension
rayo-freeswitch extends the Rayo specification and has its base namespace at urn:xmpp:rayo:freeswitch
. It provides the means to access the FreeSWITCH Inbound Event Socket interface via Rayo.
Events are sent by FS to all subscribing clients that registered using the "event" command. They are propagated by Rayo to all registered parties by way of an XMPP presence stanza. The following is the minimum data sent for a FreeSWITCH event (more information)
Event-Name: RE_SCHEDULE
Core-UUID: 6d2375b0-5183-11e1-b24c-f527b57af954
FreeSWITCH-Hostname: freeswitch.local
FreeSWITCH-Switchname: freeswitch.local
FreeSWITCH-IPv4: 127.0.0.1
FreeSWITCH-IPv6: ::1
Event-Date-Local: 2012-02-07 19:36:31
Event-Date-GMT: Tue, 07 Feb 2012 18:36:31 GMT
Event-Date-Timestamp: 1328639791116026
Event-Calling-File: switch_scheduler.c
Event-Calling-Function: switch_scheduler_execute
Event-Calling-Line-Number: 65
Event-Sequence: 3349
Which will translate to the following XMPP stanza:
<presence to="[email protected]/1" from="[email protected]">
<event xmlns="urn:xmpp:rayo:freeswitch:ies:1" name="RE_SCHEDULE">
<attribute name="Unique-ID" value="005f03fa-c803-428e-92cb-10534ac780dd"/>
<attribute name="Core-UUID" value="6d2375b0-5183-11e1-b24c-f527b57af954"/>
<attribute name="FreeSWITCH-Hostname" value="freeswitch.local"/>
<attribute name="FreeSWITCH-Switchname" value="freeswitch.local"/>
<attribute name="FreeSWITCH-IPv4" value="127.0.0.1"/>
<attribute name="FreeSWITCH-IPv6" value="::1"/>
<attribute name="Event-Date-Local" value="2012-02-07 19:36:31"/>
<attribute name="Event-Date-GMT" value="Tue, 07 Feb 2012 18:36:31 GMT"/>
<attribute name="Event-Date-Timestamp" value="1328639791116026"/>
<attribute name="Event-Calling-File" value="switch_scheduler.c"/>
<attribute name="Event-Calling-Function" value="switch_scheduler_execute"/>
<attribute name="Event-Calling-Line-Number" value="65"/>
<attribute name="Event-Sequence" value="3349"/>
</event>
</presence>
The from attribute on presence will be of the form "[email protected]" if the event has a Unique-ID and thus comes from a call, or just "call.rayo.net" if not. The above example adds the ID for display purposes.
All IES commands follow the same syntax and use the "command" element inside an , specifying the command in the name attribute and adding "param" elements, with optional names for usage with specific commands. A simple call to "api" is done in IES as follows:
api originate {foo=bar}sofia/mydomain.com/[email protected] 1000
The equivalent command in Rayo will be:
<iq id="1234" type="set" to="[email protected]/1" from="[email protected]/1">
<command xmlns="urn:xmpp:rayo:freeswitch:ies:1" name="originate">
<param value="{foo=bar}sofia/mydomain.com/[email protected]"/>
<param value="1000"/>
</command>
</iq>
In the case of a command with named parameters, like "sendmsg" as follows:
sendmsg abc123
call-command: execute
execute-app-name: playback
execute-app-arg: /tmp/test.wav
The resulting command uses the "name" attribute for parameters:
<iq id="1234" type="set" to="[email protected]/1" from="[email protected]/1">
<command xmlns="urn:xmpp:rayo:freeswitch:ies:1" name="sendmsg">
<param name="call-command" value="execute"/>
<param name="execute-app-name" value="playback"/>
<param name="execute-app-arg" value="/tmp/test.wav"/>
</command>
</iq>
When an action is executed, IES will immediately return a response in a synchronous fashion. The "bgapi" action will return an extended response with a Job-ID that indicates the action has been queued for background processing. The ID will be used to relate the correct events to the component for completion. Other components will have different events bound to them, such as PLAYBACK_END for Output. An example response would be as follows, including an unique ID assigned by the server to the component:
<iq id='1234' type='result' to='[email protected]/1' from='call.rayo.net'>
<ref id='fgh4590' xmlns='urn:xmpp:rayo:1'/>
</iq>