During all this little tutorial on events, I will use an intranet connection. If you need to, use HTTPS instead of HTTP.
In HTTPS the event port used is 8016 and in HTTP the port used is 8014.
Subscription
For this example, I want to subscribe to events to user oxe19141.
- First, you need to do a POST query to this URL :
http://o2g-instance1.ale-aapp.com/api/rest/1.0/subscriptions/
with this body :
{
"filter":
{
"selectors":
[
{"ids": [ "oxe19141" ],"names": [ "telephony" ]},
{"ids": [ "oxe19141" ],"names": [ "eventSummary" ]}
]
},
"version":"1.0"
}
- If the request worked you have a "Status: 200 OK" and the response body will return us the URL to use for a long polling and the "subscriptionId", mandatory if you want to unsubscribe to someone :
{
"subscriptionId": "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZG1pbkM1IiwiaWF0IjoxNTM3NDUwMTg2fQ.jDDsEPtoW3Ae8Fiw5YLWE9MdflEcMz-RoWLweAtPDvS",
"publicPollingUrl": "http://o2g-instance1.ale-aapp.com:8014/OTEvents?subscriptionId=eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZG1pbkM1IiwiaWF0IjoxNTM3NDUwMTg2fQ.jDDsEPtoW3Ae8Fiw5YLWE9MdflEcMz-RoWLweAtPDvS",
"privatePollingUrl": "http://o2g-instance1.ale-aapp.com:8014/OTEvents?subscriptionId=eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZG1pbkM1IiwiaWF0IjoxNTM3NDUwMTg2fQ.jDDsEPtoW3Ae8Fiw5YLWE9MdflEcMz-RoWLweAtPDvS",
"status": "ACCEPTED",
"mode": "CHUNK",
"format": "JSON"
}
Long Polling
In this example, my device (subscribed) is 19141 and i will have a call from 19140.
- Now that you have your "PollingUrl", open your favorite browser (in my case chrome) and past your URL.
- If it's all right, you have the "Chunck started" status.
- Now I connect my device 19141 who is a softphone. You can see his state is "FREE"
- Now the 19140 call the 19141. You can see that the "state" change to "RINGING_INCOMING". You are able to see the phone number of the device who call you ("participants") and more informations on him.
- During the call, you can see a lot of informations. Your "state" change to "BUSY" for example.
- Now, the 19140 device stopped the call. The 19141's state change to "FREE"
Unsubscribe
- To unsubscribe someone you just have to do a DELETE on
http://o2g-instance1.ale-aapp.com/api/rest/1.0/subscriptions/
+ "subscriptionId"
for example :
http://o2g-instance1.ale-aapp.com/api/rest/1.0/subscriptions/eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZG1pbkM1IiwiaWF0IjoxNTM3NDUwMTg2fQ.jDDsEPtoW3Ae8Fiw5YLWE9MdflEcMz-RoWLweAtPDvS
- On succes you have the "204 No Content" status.