[asterisk-users] How to get call progress events from WebSocket connected to Asterisk 12 ARI events API

2013-09-12 Thread Jim Fathman
Hello,

I am experimenting with Asterisk 12.0.0 alpha1.  I have a couple of SIP
phones working.  Good.  I can retrieve data using curl to interact with the
new Asterisk REST API (ARI).  Good.

Now I want to use the new ARI events API, which requires a WebSocket
connection.  I am using Node.js for the client, and have a stable
connection to ARI events on the Asterisk 12 server.

What I hope for is that my Node.js client will receive call related events
in JSON format messages as call activity occurs on the Asterisk server.
 But I don't know how to request this information via the API.

Do I need to specify something in the query string used for the initial
WebSocket connection?  Or do I need to send some kind of event subscription
messages within the WebSocket once connected?

Any guidance, sample client code, or web reference would be most welcome.

Thanks.

Jim

Node.js client connecting to ARI events:

  // app.js

  var WebSocket = require('ws');

  var ws = new WebSocket('ws://192.168.1.125:8088/ari/events?app=node-client
',
{ headers: {
Authorization: 'Basic Y29tZXQ6MTIzNA=='
  },
  protocol: 'ari',
});

  ws.on('open', function() {
console.log('connected');
  });

  ws.on('message', function(message) {
console.log('received: %s', message);
  });

  ws.on('error', function(err) {
console.log(err);
  });

It runs and indicates a successful connection:

  $ node app.js
  connected

The Asterisk CLI logs the successful connection:

  == WebSocket connection from '192.168.1.125:34792' for protocol 'ari'
accepted using version '13'
  Creating Stasis app 'node-client'
--
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Re: [asterisk-users] How to get call progress events from WebSocket connected to Asterisk 12 ARI events API

2013-09-12 Thread Joshua Colp

Jim Fathman wrote:

Hello,


Bonjour!


I am experimenting with Asterisk 12.0.0 alpha1.  I have a couple of SIP
phones working.  Good.  I can retrieve data using curl to interact with
the new Asterisk REST API (ARI).  Good.

Now I want to use the new ARI events API, which requires a WebSocket
connection.  I am using Node.js for the client, and have a stable
connection to ARI events on the Asterisk 12 server.

What I hope for is that my Node.js client will receive call related
events in JSON format messages as call activity occurs on the Asterisk
server.  But I don't know how to request this information via the API.

Do I need to specify something in the query string used for the initial
WebSocket connection?  Or do I need to send some kind of event
subscription messages within the WebSocket once connected?


David Lee (ARI man supreme) is currently working on an issue [1] which 
covers support for subscribing for this information for delivery over 
the WebSocket connection in a branch [2]. I'd expect this to be 
integrated into 12 within a few weeks. I believe it should cover what 
you want to do.


[1] https://issues.asterisk.org/jira/browse/ASTERISK-22451
[2] 
http://svn.digium.com/svn/asterisk/team/dlee/ASTERISK-22451-ari-subscribe/


Cheers,

--
Joshua Colp
Digium, Inc. | Senior Software Developer
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at:  www.digium.com  & www.asterisk.org

--
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
  http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
  http://lists.digium.com/mailman/listinfo/asterisk-users


Re: [asterisk-users] How to get call progress events from WebSocket connected to Asterisk 12 ARI events API

2013-09-12 Thread Jim Fathman
Joshua,

Thanks, I am really looking forward to the new REST API support.  I know it
will take a while to get all the pieces in place.

I don't know what the Digium vision is for the REST API, but what I would
like to see is a simple WebSocket connection that can receive granular
events for all the call activity on the Asterisk server.  This would allow
a Node.js application to know everything that is happening so it could
support UC web apps that also connect to the Node.js server.

If the ARI has enough granularity to let the Node.js application make
real-time call control decisions and manage call progress and features,
then the Asterisk servers(s) could be used as SIP and media edge devices
with third party call control running on the Node.js platform.

Jim



On Thu, Sep 12, 2013 at 10:07 AM, Joshua Colp  wrote:

> Jim Fathman wrote:
>
>> Hello,
>>
>
> Bonjour!
>
>
>  I am experimenting with Asterisk 12.0.0 alpha1.  I have a couple of SIP
>> phones working.  Good.  I can retrieve data using curl to interact with
>> the new Asterisk REST API (ARI).  Good.
>>
>> Now I want to use the new ARI events API, which requires a WebSocket
>> connection.  I am using Node.js for the client, and have a stable
>> connection to ARI events on the Asterisk 12 server.
>>
>> What I hope for is that my Node.js client will receive call related
>> events in JSON format messages as call activity occurs on the Asterisk
>> server.  But I don't know how to request this information via the API.
>>
>> Do I need to specify something in the query string used for the initial
>> WebSocket connection?  Or do I need to send some kind of event
>> subscription messages within the WebSocket once connected?
>>
>
> David Lee (ARI man supreme) is currently working on an issue [1] which
> covers support for subscribing for this information for delivery over the
> WebSocket connection in a branch [2]. I'd expect this to be integrated into
> 12 within a few weeks. I believe it should cover what you want to do.
>
> [1] 
> https://issues.asterisk.org/**jira/browse/ASTERISK-22451
> [2] http://svn.digium.com/svn/**asterisk/team/dlee/ASTERISK-**
> 22451-ari-subscribe/
>
> Cheers,
>
> --
> Joshua Colp
> Digium, Inc. | Senior Software Developer
> 445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
> Check us out at:  www.digium.com  & www.asterisk.org
>
> --
> __**__**_
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
> New to Asterisk? Join us for a live introductory webinar every Thurs:
>   http://www.asterisk.org/hello
>
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
>   
> http://lists.digium.com/**mailman/listinfo/asterisk-**users
>
--
_
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
   http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users