2015-09-05 03:26:55 +08:00
|
|
|
# Periodically check the status of the WebRTC call, when a call has been established attempt to hangup,
|
|
|
|
# retry if a call is in progress, send the leave voice conference message to BBB
|
|
|
|
@exitVoiceCall = (event) ->
|
2015-09-14 22:07:35 +08:00
|
|
|
if not Meteor.config.useSIPAudio
|
|
|
|
leaveWebRTCVoiceConference_verto();
|
|
|
|
cur_call = null;
|
|
|
|
return
|
2015-09-05 03:26:55 +08:00
|
|
|
else
|
2015-09-14 22:07:35 +08:00
|
|
|
# To be called when the hangup is initiated
|
|
|
|
hangupCallback = ->
|
|
|
|
console.log "Exiting Voice Conference"
|
|
|
|
|
|
|
|
# Checks periodically until a call is established so we can successfully end the call
|
|
|
|
# clean state
|
|
|
|
getInSession("triedHangup", false)
|
|
|
|
# function to initiate call
|
|
|
|
(checkToHangupCall = (context) ->
|
|
|
|
# if an attempt to hang up the call is made when the current session is not yet finished, the request has no effect
|
|
|
|
# keep track in the session if we haven't tried a hangup
|
|
|
|
if BBB.getCallStatus() isnt null and !getInSession("triedHangup")
|
|
|
|
console.log "Attempting to hangup on WebRTC call"
|
|
|
|
if BBB.amIListenOnlyAudio() # notify BBB-apps we are leaving the call call if we are listen only
|
|
|
|
Meteor.call('listenOnlyRequestToggle', BBB.getMeetingId(), getInSession("userId"), getInSession("authToken"), false)
|
|
|
|
BBB.leaveVoiceConference hangupCallback
|
|
|
|
getInSession("triedHangup", true) # we have hung up, prevent retries
|
|
|
|
notification_WebRTCAudioExited()
|
|
|
|
else
|
|
|
|
console.log "RETRYING hangup on WebRTC call in #{Meteor.config.app.WebRTCHangupRetryInterval} ms"
|
|
|
|
setTimeout checkToHangupCall, Meteor.config.app.WebRTCHangupRetryInterval # try again periodically
|
|
|
|
)(@) # automatically run function
|
|
|
|
return false
|
2015-09-05 03:26:55 +08:00
|
|
|
|
|
|
|
# join the conference. If listen only send the request to the server
|
2015-09-23 00:09:29 +08:00
|
|
|
@joinVoiceCall = (event, options) ->
|
2015-09-05 03:26:55 +08:00
|
|
|
if !isWebRTCAvailable()
|
|
|
|
notification_WebRTCNotSupported()
|
|
|
|
return
|
|
|
|
|
2015-09-23 00:09:29 +08:00
|
|
|
# isListenOnly ?= trueoptions
|
2015-09-05 03:26:55 +08:00
|
|
|
|
2015-09-14 22:07:35 +08:00
|
|
|
if not Meteor.config.useSIPAudio
|
|
|
|
#
|
|
|
|
# "click #joinAudio": (event) ->
|
|
|
|
# displayVertoVideo()
|
2015-10-09 04:14:13 +08:00
|
|
|
if options.watchOnly?
|
|
|
|
toggleWhiteboardVideo("video")
|
2015-09-14 22:07:35 +08:00
|
|
|
# return
|
|
|
|
wasCallSuccessful = false
|
|
|
|
debuggerCallback = (message) ->
|
|
|
|
console.log("CALLBACK: "+JSON.stringify(message));
|
|
|
|
#
|
|
|
|
# Beginning of hacky method to make Firefox media calls succeed.
|
|
|
|
# Always fail the first time. Retry on failure.
|
|
|
|
#
|
|
|
|
if !!navigator.mozGetUserMedia and message.errorcode is 1001
|
2015-09-23 00:09:29 +08:00
|
|
|
callIntoConference_verto(extension, conferenceUsername, conferenceIdNumber, ((m) -> console.log("CALLBACK: "+JSON.stringify(m))), "webcam", options)
|
2015-09-14 22:07:35 +08:00
|
|
|
#
|
|
|
|
# End of hacky method
|
|
|
|
#
|
2015-09-23 00:09:29 +08:00
|
|
|
callIntoConference_verto(extension, conferenceUsername, conferenceIdNumber, debuggerCallback, "webcam", options);
|
2015-09-14 22:07:35 +08:00
|
|
|
return
|
|
|
|
else
|
|
|
|
# create voice call params
|
|
|
|
joinCallback = (message) ->
|
|
|
|
console.log "Beginning WebRTC Conference Call"
|
2015-09-05 03:26:55 +08:00
|
|
|
|
2015-09-14 22:07:35 +08:00
|
|
|
notification_WebRTCAudioJoining()
|
2015-10-01 03:41:59 +08:00
|
|
|
if options.isListenOnly
|
2015-09-14 22:07:35 +08:00
|
|
|
Meteor.call('listenOnlyRequestToggle', BBB.getMeetingId(), getInSession("userId"), getInSession("authToken"), true)
|
2015-10-01 03:41:59 +08:00
|
|
|
|
|
|
|
requestedListenOnly = options.isListenOnly?
|
|
|
|
BBB.joinVoiceConference joinCallback, requestedListenOnly # make the call #TODO should we apply role permissions to this action?
|
2015-09-05 03:26:55 +08:00
|
|
|
|
2015-09-14 22:07:35 +08:00
|
|
|
return false
|