Skip to content

Instantly share code, notes, and snippets.

@aylarov
Created July 14, 2016 11:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aylarov/103a1f29b4e9a3eba7da1f7ad2a2d32a to your computer and use it in GitHub Desktop.
Save aylarov/103a1f29b4e9a3eba7da1f7ad2a2d32a to your computer and use it in GitHub Desktop.
var username;
VoxEngine.addEventListener(AppEvents.CallAlerting, function (e) {
username = e.callerid;
var call = VoxEngine.callConference("user_" + e.callerid, e.callerid, e.displayName, e.headers);
VoxEngine.easyProcess(e.call, call, function (c1, c2) {
e.call.sendMessage(JSON.stringify({
event: "userconf_connected",
name: e.callerid
}));
});
e.call.removeEventListener(CallEvents.Disconnected);
call.removeEventListener(CallEvents.Disconnected);
e.call.addEventListener(CallEvents.Disconnected, endSession);
call.addEventListener(CallEvents.Disconnected, endSession);
});
function endSession(e) {
Net.httpRequestAsync("https://demos.voximplant.com/walkietalkie/auth.php?action=LEAVE_CONFERENCE&username=" + encodeURIComponent(username))
.then(function (result) {
Logger.write(JSON.stringify(result));
});
VoxEngine.terminate();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment