asterisk / node-ari-client

Node.js client for ARI. This library is best effort with limited support.
Other
250 stars 98 forks source link

how to use snoopChannel #108

Closed mpbanna closed 6 years ago

mpbanna commented 6 years ago

Hello , I want to use spy and whisper using snoopChannel , but i do not understand how to use this snoopChannel() method.

Actually my need is that, one user on a channel wants to whisper/spy a talk running between two caller(means both caller's channels are in a bridge), so how i use this method please give me example code here. and also give me possible value of arguments 'spy' and 'whisper'

Thanks.

jcolp commented 6 years ago

There are various methods to seek help with Asterisk. I'd suggest using the community site[1] or the asterisk-app-dev mailing list[2].

[1] https://community.asterisk.org/ [2] http://lists.digium.com/pipermail/asterisk-app-dev/

mpbanna commented 5 years ago

Thanks @jcolp , for giving me right place for such support, now i found solution and here i am writing my sample code:-

client.channels.originate( {endpoint: 'SIP/sip1/XXXXXXXXXX', app: appName, appArgs: 'dialed', callerId: 'XXXXXXXXXX'}, function (err, childChannel) { console.log(err) }); client.on('StasisStart', function (event, channel) { console.log('statsis started:', channel.id); var channelId = '1532508373.1465012'; //This channelId whom you want to snoop, and for my case this channel is in other bridge with other caller. client.channels.snoopChannel( {app: appName, channelId: channelId, snoopId: channel.id + '_snoop', spy: 'both', whisper: 'out'}, function (err, channelIn) { console.log('snoopChannel::', err, channelIn.id)

                var bridge = client.Bridge();
                bridge.create({type: 'mixing, dtmf_events'}, function (err, bridge) {
                    if (err) {
                        console.log(err);
                        return;
                    }
                    sourceBridgeId = bridge.id;
                    client.bridges.addChannel({bridgeId: sourceBridgeId, channel: channel.id}, function (err) {
                        console.log('addChannel1::', err)
                    });
                    client.bridges.addChannel({bridgeId: sourceBridgeId, channel: channelIn.id}, function (err) {
                        console.log('addChannel2::', err)
                    });
                });

            }
    );
});