diff --git a/client/views/app/tabBar/membersList.coffee b/client/views/app/tabBar/membersList.coffee index 2d6bfcf1346..1fc9d07b6e1 100644 --- a/client/views/app/tabBar/membersList.coffee +++ b/client/views/app/tabBar/membersList.coffee @@ -6,6 +6,9 @@ Template.membersList.helpers videoActive: -> return WebRTC.getInstanceByRoomId(Session.get('openedRoom')).localUrl.get()? or WebRTC.getInstanceByRoomId(Session.get('openedRoom')).remoteItems.get()?.length > 0 + callInProgress: -> + return WebRTC.getInstanceByRoomId(Session.get('openedRoom')).callInProgress.get() + audioEnabled: -> return WebRTC.getInstanceByRoomId(Session.get('openedRoom')).audioEnabled.get() @@ -154,6 +157,9 @@ Template.membersList.events 'click .start-video-call': -> WebRTC.getInstanceByRoomId(Session.get('openedRoom')).startCall() + 'click .join-video-call': -> + WebRTC.getInstanceByRoomId(Session.get('openedRoom')).joinCall() + 'click .stop-call': -> WebRTC.getInstanceByRoomId(Session.get('openedRoom')).stop() diff --git a/client/views/app/tabBar/membersList.html b/client/views/app/tabBar/membersList.html index 2c39945e31e..88e10c434ee 100644 --- a/client/views/app/tabBar/membersList.html +++ b/client/views/app/tabBar/membersList.html @@ -56,7 +56,11 @@

{{#unless videoActive}} - + {{#if callInProgress}} + + {{else}} + + {{/if}} {{/unless}}
diff --git a/packages/rocketchat-webrtc/WebRTCClass.coffee b/packages/rocketchat-webrtc/WebRTCClass.coffee index a92d2a319fb..ff373c6e8f2 100644 --- a/packages/rocketchat-webrtc/WebRTCClass.coffee +++ b/packages/rocketchat-webrtc/WebRTCClass.coffee @@ -31,6 +31,10 @@ class WebRTCTransportClass if @callbacks['onRemoteDescription']?.length > 0 fn(data) for fn in @callbacks['onRemoteDescription'] + when 'status' + if @callbacks['onRemoteStatus']?.length > 0 + fn(data) for fn in @callbacks['onRemoteStatus'] + startCall: -> @log 'WebRTCTransportClass - startCall', @webrtcInstance.room, @webrtcInstance.selfId RocketChat.Notifications.notifyRoom @webrtcInstance.room, 'webrtc', 'call', @@ -49,6 +53,10 @@ class WebRTCTransportClass @log 'WebRTCTransportClass - sendDescription', data, @webrtcInstance.room RocketChat.Notifications.notifyRoom @webrtcInstance.room, 'webrtc', 'description', data + sendStatus: (data) -> + @log 'WebRTCTransportClass - sendStatus', data, @webrtcInstance.room + RocketChat.Notifications.notifyRoom @webrtcInstance.room, 'webrtc', 'status', data + onRemoteCall: (fn) -> @callbacks['onRemoteCall'] ?= [] @callbacks['onRemoteCall'].push fn @@ -65,6 +73,10 @@ class WebRTCTransportClass @callbacks['onRemoteDescription'] ?= [] @callbacks['onRemoteDescription'].push fn + onRemoteStatus: (fn) -> + @callbacks['onRemoteStatus'] ?= [] + @callbacks['onRemoteStatus'].push fn + class WebRTCClass config: @@ -88,6 +100,7 @@ class WebRTCClass @remoteItems = new ReactiveVar [] @remoteItemsById = new ReactiveVar {} + @callInProgress = new ReactiveVar false @audioEnabled = new ReactiveVar true @videoEnabled = new ReactiveVar true @localUrl = new ReactiveVar @@ -98,6 +111,9 @@ class WebRTCClass @transport.onRemoteJoin @onRemoteJoin.bind @ @transport.onRemoteCandidate @onRemoteCandidate.bind @ @transport.onRemoteDescription @onRemoteDescription.bind @ + @transport.onRemoteStatus @onRemoteStatus.bind @ + + Meteor.setInterval @broadcastStatus.bind(@), 1000 log: -> if @debug is true @@ -140,6 +156,38 @@ class WebRTCClass @remoteItems.set items @remoteItemsById.set itemsById + resetCallInProgress: -> + @callInProgress.set false + + broadcastStatus: -> + if @active isnt true then return + + @transport.sendStatus + from: @selfId + remoteConnectionIds: Object.keys(@peerConnections) + + ### + @param data {Object} + from {String} + remoteConnectionIds {Array[String]} + ### + onRemoteStatus: (data) -> + # @log 'onRemoteStatus', arguments + + @callInProgress.set true + + Meteor.clearTimeout @callInProgressTimeout + @callInProgressTimeout = Meteor.setTimeout @resetCallInProgress.bind(@), 2000 + + if @active isnt true then return + + ids = [data.from].concat data.remoteConnectionIds + + for id in ids + if id isnt @selfId and not @peerConnections[id]? + @log 'reconnecting with', id + @onRemoteJoin + from: id ### @param id {String}