Created
July 14, 2016 11:37
-
-
Save aylarov/103a1f29b4e9a3eba7da1f7ad2a2d32a 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
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