Last active
July 14, 2016 11:40
-
-
Save aylarov/394329194339aca2e942474ecb14bf9d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Channel Conference | |
require(Modules.Conference); | |
require(Modules.Player); | |
var conf, | |
calls = []; | |
VoxEngine.addEventListener(AppEvents.Started, function(e) { | |
conf = VoxEngine.createConference(); | |
}); | |
VoxEngine.addEventListener(AppEvents.CallAlerting, function(e) { | |
e.call.addEventListener(CallEvents.Connected, handleCallConnected); | |
e.call.addEventListener(CallEvents.Disconnected, handleCallDisconnected); | |
e.call.answer(); | |
}); | |
function handleCallConnected(e) { | |
calls.push(e.call); | |
var player = VoxEngine.createTTSPlayer("Channel connected"); | |
player.sendMediaTo(e.call); | |
player.addEventListener(PlayerEvents.PlaybackFinished, function(pevent) { | |
VoxEngine.sendMediaBetween(e.call, conf); | |
}); | |
} | |
function handleCallDisconnected(e) { | |
for (var i=0;i < calls.length; i++) { | |
if (calls[i] == e.call) { | |
calls.splice(i, 1); | |
break; | |
} | |
} | |
if (calls.length === 0) VoxEngine.terminate(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment