2016-10-02 17:16:02 +08:00
|
|
|
/* global $ */
|
2016-10-18 12:34:19 -04:00
|
|
|
|
|
|
|
import SimpleWebRTC from 'simplewebrtc'
|
2016-10-18 20:29:21 -04:00
|
|
|
import SocketIoConnection from 'simplewebrtc/socketioconnection'
|
2016-10-18 12:34:19 -04:00
|
|
|
|
|
|
|
import Active from '../Active'
|
2017-01-03 16:12:58 -05:00
|
|
|
import Cable from '../Cable'
|
2016-10-02 17:16:02 +08:00
|
|
|
import DataModel from '../DataModel'
|
2016-10-18 12:34:19 -04:00
|
|
|
import JIT from '../JIT'
|
|
|
|
import Util from '../Util'
|
|
|
|
import Views from '../Views'
|
2016-12-21 03:56:29 -05:00
|
|
|
import { ChatView } from '../Views'
|
2016-10-18 12:34:19 -04:00
|
|
|
import Visualize from '../Visualize'
|
|
|
|
|
|
|
|
import {
|
2016-10-21 09:29:04 -04:00
|
|
|
JUNTO_UPDATED,
|
2016-10-18 12:34:19 -04:00
|
|
|
INVITED_TO_CALL,
|
|
|
|
INVITED_TO_JOIN,
|
|
|
|
CALL_ACCEPTED,
|
|
|
|
CALL_DENIED,
|
|
|
|
INVITE_DENIED,
|
|
|
|
CALL_IN_PROGRESS,
|
|
|
|
CALL_STARTED,
|
2016-10-21 09:29:04 -04:00
|
|
|
MAPPER_LIST_UPDATED,
|
2016-10-18 12:34:19 -04:00
|
|
|
MAPPER_JOINED_CALL,
|
|
|
|
MAPPER_LEFT_CALL,
|
|
|
|
NEW_MAPPER,
|
|
|
|
LOST_MAPPER,
|
|
|
|
PEER_COORDS_UPDATED,
|
2017-01-03 16:12:58 -05:00
|
|
|
TOPIC_DRAGGED
|
2016-10-18 12:34:19 -04:00
|
|
|
} from './events'
|
|
|
|
|
|
|
|
import {
|
2016-10-21 09:29:04 -04:00
|
|
|
juntoUpdated,
|
2016-10-18 12:34:19 -04:00
|
|
|
invitedToCall,
|
|
|
|
invitedToJoin,
|
|
|
|
callAccepted,
|
|
|
|
callDenied,
|
|
|
|
inviteDenied,
|
|
|
|
callInProgress,
|
|
|
|
callStarted,
|
2016-10-21 09:29:04 -04:00
|
|
|
mapperListUpdated,
|
2016-10-18 12:34:19 -04:00
|
|
|
mapperJoinedCall,
|
|
|
|
mapperLeftCall,
|
|
|
|
peerCoordsUpdated,
|
|
|
|
newMapper,
|
|
|
|
lostMapper,
|
2017-01-03 16:12:58 -05:00
|
|
|
topicDragged
|
2016-10-18 12:34:19 -04:00
|
|
|
} from './receivable'
|
|
|
|
|
|
|
|
import {
|
|
|
|
joinMap,
|
|
|
|
leaveMap,
|
|
|
|
checkForCall,
|
|
|
|
acceptCall,
|
|
|
|
denyCall,
|
|
|
|
denyInvite,
|
|
|
|
inviteToJoin,
|
|
|
|
inviteACall,
|
|
|
|
joinCall,
|
|
|
|
leaveCall,
|
|
|
|
sendCoords,
|
2016-10-21 09:29:04 -04:00
|
|
|
sendMapperInfo,
|
2017-01-03 16:12:58 -05:00
|
|
|
dragTopic
|
2016-10-18 12:34:19 -04:00
|
|
|
} from './sendable'
|
|
|
|
|
2016-10-18 12:56:30 -04:00
|
|
|
let Realtime = {
|
2016-10-21 09:29:04 -04:00
|
|
|
juntoState: { connectedPeople: {}, liveMaps: {} },
|
2016-10-18 12:34:19 -04:00
|
|
|
videoId: 'video-wrapper',
|
|
|
|
socket: null,
|
|
|
|
webrtc: null,
|
|
|
|
readyToCall: false,
|
|
|
|
mappersOnMap: {},
|
|
|
|
disconnected: false,
|
|
|
|
chatOpen: false,
|
|
|
|
soundId: null,
|
|
|
|
broadcastingStatus: false,
|
|
|
|
inConversation: false,
|
|
|
|
localVideo: null,
|
2016-10-02 17:16:02 +08:00
|
|
|
'junto_spinner_darkgrey.gif': '',
|
2016-11-07 15:25:08 -05:00
|
|
|
init: function(serverData) {
|
2016-10-18 12:34:19 -04:00
|
|
|
var self = Realtime
|
|
|
|
|
|
|
|
self.addJuntoListeners()
|
|
|
|
|
2016-11-24 14:40:14 -05:00
|
|
|
self.socket = new SocketIoConnection({
|
|
|
|
url: serverData['REALTIME_SERVER'],
|
|
|
|
socketio: {
|
|
|
|
// don't poll forever if in development
|
|
|
|
reconnectionAttempts: serverData.RAILS_ENV === 'development' ? 5 : Infinity
|
|
|
|
}
|
|
|
|
})
|
2016-10-02 17:16:02 +08:00
|
|
|
self['junto_spinner_darkgrey.gif'] = serverData['junto_spinner_darkgrey.gif']
|
2016-11-07 15:25:08 -05:00
|
|
|
|
|
|
|
self.socket.on('connect', function() {
|
2016-10-18 12:34:19 -04:00
|
|
|
console.log('connected')
|
2017-01-03 16:12:58 -05:00
|
|
|
if (Active.Map && Active.Mapper && Active.Map.authorizeToEdit(Active.Mapper)) {
|
|
|
|
self.checkForCall()
|
|
|
|
self.joinMap()
|
|
|
|
}
|
2016-10-18 12:34:19 -04:00
|
|
|
subscribeToEvents(self, self.socket)
|
2017-01-03 16:12:58 -05:00
|
|
|
self.disconnected = false
|
2016-10-18 12:34:19 -04:00
|
|
|
})
|
2016-11-07 15:25:08 -05:00
|
|
|
self.socket.on('disconnect', function() {
|
2016-10-18 12:34:19 -04:00
|
|
|
self.disconnected = true
|
|
|
|
})
|
|
|
|
|
|
|
|
if (Active.Mapper) {
|
|
|
|
self.webrtc = new SimpleWebRTC({
|
|
|
|
connection: self.socket,
|
|
|
|
localVideoEl: self.videoId,
|
|
|
|
remoteVideosEl: '',
|
|
|
|
debug: true,
|
2016-11-07 15:25:08 -05:00
|
|
|
detectSpeakingEvents: false, // true,
|
2016-10-18 12:34:19 -04:00
|
|
|
autoAdjustMic: false, // true,
|
|
|
|
autoRequestMedia: false,
|
|
|
|
localVideo: {
|
|
|
|
autoplay: true,
|
|
|
|
mirror: true,
|
|
|
|
muted: true
|
|
|
|
},
|
|
|
|
media: {
|
|
|
|
video: true,
|
|
|
|
audio: true
|
|
|
|
},
|
|
|
|
nick: Active.Mapper.id
|
|
|
|
})
|
2016-11-07 15:25:08 -05:00
|
|
|
self.webrtc.webrtc.on('iceFailed', function(peer) {
|
2016-10-18 12:34:19 -04:00
|
|
|
console.log('local ice failure', peer)
|
|
|
|
// local ice failure
|
|
|
|
})
|
2016-11-07 15:25:08 -05:00
|
|
|
self.webrtc.webrtc.on('connectivityError', function(peer) {
|
2016-10-18 12:34:19 -04:00
|
|
|
console.log('remote ice failure', peer)
|
|
|
|
// remote ice failure
|
|
|
|
})
|
|
|
|
|
|
|
|
var $video = $('<video></video>').attr('id', self.videoId)
|
|
|
|
self.localVideo = {
|
|
|
|
$video: $video,
|
|
|
|
view: new Views.VideoView($video[0], $('body'), 'me', true, {
|
|
|
|
DOUBLE_CLICK_TOLERANCE: 200,
|
|
|
|
avatar: Active.Mapper ? Active.Mapper.get('image') : ''
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
self.room = new Views.Room({
|
|
|
|
webrtc: self.webrtc,
|
|
|
|
socket: self.socket,
|
|
|
|
room: 'global',
|
|
|
|
$video: self.localVideo.$video,
|
|
|
|
myVideoView: self.localVideo.view,
|
2016-12-21 03:56:29 -05:00
|
|
|
config: { DOUBLE_CLICK_TOLERANCE: 200 }
|
2016-10-18 12:34:19 -04:00
|
|
|
})
|
|
|
|
self.room.videoAdded(self.handleVideoAdded)
|
2017-01-03 16:12:58 -05:00
|
|
|
|
|
|
|
self.startActiveMap()
|
2016-10-18 12:34:19 -04:00
|
|
|
} // if Active.Mapper
|
|
|
|
},
|
2016-11-07 15:25:08 -05:00
|
|
|
addJuntoListeners: function() {
|
2016-10-18 12:34:19 -04:00
|
|
|
var self = Realtime
|
|
|
|
|
2016-12-21 03:56:29 -05:00
|
|
|
$(document).on(ChatView.events.openTray, function() {
|
2016-10-18 12:34:19 -04:00
|
|
|
$('.main').addClass('compressed')
|
|
|
|
self.chatOpen = true
|
|
|
|
self.positionPeerIcons()
|
|
|
|
})
|
2016-12-21 03:56:29 -05:00
|
|
|
$(document).on(ChatView.events.closeTray, function() {
|
2016-10-18 12:34:19 -04:00
|
|
|
$('.main').removeClass('compressed')
|
|
|
|
self.chatOpen = false
|
|
|
|
self.positionPeerIcons()
|
|
|
|
})
|
2016-12-21 03:56:29 -05:00
|
|
|
$(document).on(ChatView.events.videosOn, function() {
|
2016-10-18 12:34:19 -04:00
|
|
|
$('#wrapper').removeClass('hideVideos')
|
|
|
|
})
|
2016-12-21 03:56:29 -05:00
|
|
|
$(document).on(ChatView.events.videosOff, function() {
|
2016-10-18 12:34:19 -04:00
|
|
|
$('#wrapper').addClass('hideVideos')
|
|
|
|
})
|
2016-12-21 03:56:29 -05:00
|
|
|
$(document).on(ChatView.events.cursorsOn, function() {
|
2016-10-18 12:34:19 -04:00
|
|
|
$('#wrapper').removeClass('hideCursors')
|
|
|
|
})
|
2016-12-21 03:56:29 -05:00
|
|
|
$(document).on(ChatView.events.cursorsOff, function() {
|
2016-10-18 12:34:19 -04:00
|
|
|
$('#wrapper').addClass('hideCursors')
|
|
|
|
})
|
|
|
|
},
|
2016-11-07 15:25:08 -05:00
|
|
|
startActiveMap: function() {
|
2016-10-18 12:34:19 -04:00
|
|
|
var self = Realtime
|
|
|
|
if (Active.Map && Active.Mapper) {
|
|
|
|
if (Active.Map.authorizeToEdit(Active.Mapper)) {
|
|
|
|
self.turnOn()
|
2017-01-03 16:12:58 -05:00
|
|
|
self.checkForCall()
|
|
|
|
self.joinMap()
|
2016-10-18 12:34:19 -04:00
|
|
|
}
|
2016-12-21 03:56:29 -05:00
|
|
|
self.setupChat() // chat can happen on public maps too
|
2017-01-03 16:12:58 -05:00
|
|
|
Cable.subscribeToMap(Active.Map.id) // people with edit rights can still see live updates
|
2016-10-18 12:34:19 -04:00
|
|
|
}
|
|
|
|
},
|
2016-11-07 15:25:08 -05:00
|
|
|
endActiveMap: function() {
|
2016-10-18 12:34:19 -04:00
|
|
|
var self = Realtime
|
|
|
|
$(document).off('.map')
|
|
|
|
// leave the appropriate rooms to leave
|
|
|
|
if (self.inConversation) self.leaveCall()
|
|
|
|
self.leaveMap()
|
|
|
|
$('.collabCompass').remove()
|
2016-12-21 03:56:29 -05:00
|
|
|
if (self.room) self.room.leave()
|
|
|
|
ChatView.hide()
|
|
|
|
ChatView.close()
|
|
|
|
ChatView.reset()
|
2017-01-03 16:12:58 -05:00
|
|
|
Cable.unsubscribeFromMap()
|
2016-10-18 12:34:19 -04:00
|
|
|
},
|
2016-11-07 15:25:08 -05:00
|
|
|
turnOn: function(notify) {
|
2016-10-18 12:34:19 -04:00
|
|
|
var self = Realtime
|
|
|
|
$('.collabCompass').show()
|
|
|
|
self.room.room = 'map-' + Active.Map.id
|
|
|
|
self.activeMapper = {
|
|
|
|
id: Active.Mapper.id,
|
|
|
|
name: Active.Mapper.get('name'),
|
|
|
|
username: Active.Mapper.get('name'),
|
|
|
|
image: Active.Mapper.get('image'),
|
|
|
|
color: Util.getPastelColor(),
|
|
|
|
self: true
|
|
|
|
}
|
|
|
|
self.localVideo.view.$container.find('.video-cutoff').css({
|
|
|
|
border: '4px solid ' + self.activeMapper.color
|
|
|
|
})
|
2017-01-03 16:12:58 -05:00
|
|
|
self.setupLocalEvents()
|
2016-12-21 03:56:29 -05:00
|
|
|
},
|
|
|
|
setupChat: function() {
|
|
|
|
const self = Realtime
|
|
|
|
ChatView.setNewMap()
|
|
|
|
ChatView.addParticipant(self.activeMapper)
|
|
|
|
ChatView.addMessages(new DataModel.MessageCollection(DataModel.Messages), true)
|
|
|
|
ChatView.show()
|
2016-10-18 12:34:19 -04:00
|
|
|
},
|
2017-01-03 16:12:58 -05:00
|
|
|
setupLocalEvents: function() {
|
2016-10-18 12:34:19 -04:00
|
|
|
var self = Realtime
|
|
|
|
// local event listeners that trigger events
|
2017-01-03 16:12:58 -05:00
|
|
|
$(document).on(JIT.events.zoom + '.map', self.positionPeerIcons)
|
|
|
|
$(document).on(JIT.events.pan + '.map', self.positionPeerIcons)
|
|
|
|
$(document).on('mousemove.map', function(event) {
|
2016-10-18 12:34:19 -04:00
|
|
|
var pixels = {
|
|
|
|
x: event.pageX,
|
|
|
|
y: event.pageY
|
|
|
|
}
|
2016-10-25 12:28:51 +08:00
|
|
|
var coords = Util.pixelsToCoords(Visualize.mGraph, pixels)
|
2016-10-18 12:34:19 -04:00
|
|
|
self.sendCoords(coords)
|
2017-01-03 16:12:58 -05:00
|
|
|
})
|
|
|
|
$(document).on(JIT.events.topicDrag + '.map', function(event, positions) {
|
2016-10-18 12:34:19 -04:00
|
|
|
self.dragTopic(positions)
|
2017-01-03 16:12:58 -05:00
|
|
|
})
|
2016-10-18 12:34:19 -04:00
|
|
|
},
|
2016-11-07 15:25:08 -05:00
|
|
|
countOthersInConversation: function() {
|
2016-10-18 12:34:19 -04:00
|
|
|
var self = Realtime
|
|
|
|
var count = 0
|
|
|
|
for (var key in self.mappersOnMap) {
|
|
|
|
if (self.mappersOnMap[key].inConversation) count++
|
|
|
|
}
|
|
|
|
return count
|
|
|
|
},
|
2016-11-07 15:25:08 -05:00
|
|
|
handleVideoAdded: function(v, id) {
|
2016-10-18 12:34:19 -04:00
|
|
|
var self = Realtime
|
|
|
|
self.positionVideos()
|
|
|
|
v.setParent($('#wrapper'))
|
|
|
|
v.$container.find('.video-cutoff').css({
|
|
|
|
border: '4px solid ' + self.mappersOnMap[id].color
|
|
|
|
})
|
|
|
|
$('#wrapper').append(v.$container)
|
|
|
|
},
|
2016-11-07 15:25:08 -05:00
|
|
|
positionVideos: function() {
|
2016-10-18 12:34:19 -04:00
|
|
|
var self = Realtime
|
|
|
|
var videoIds = Object.keys(self.room.videos)
|
2016-11-07 15:25:08 -05:00
|
|
|
// var numOfVideos = videoIds.length
|
|
|
|
// var numOfVideosToPosition = _.filter(videoIds, function(id) {
|
|
|
|
// return !self.room.videos[id].manuallyPositioned
|
|
|
|
// }).length
|
2016-10-18 12:34:19 -04:00
|
|
|
|
|
|
|
var screenHeight = $(document).height()
|
|
|
|
var topExtraPadding = 20
|
|
|
|
var topPadding = 30
|
|
|
|
var leftPadding = 30
|
|
|
|
var videoHeight = 150
|
|
|
|
var videoWidth = 180
|
|
|
|
var column = 0
|
|
|
|
var row = 0
|
2016-11-07 15:25:08 -05:00
|
|
|
var yFormula = function() {
|
2016-10-18 12:34:19 -04:00
|
|
|
var y = topExtraPadding + (topPadding + videoHeight) * row + topPadding
|
|
|
|
if (y + videoHeight > screenHeight) {
|
|
|
|
row = 0
|
|
|
|
column += 1
|
|
|
|
y = yFormula()
|
|
|
|
}
|
|
|
|
row++
|
|
|
|
return y
|
|
|
|
}
|
2016-11-07 15:25:08 -05:00
|
|
|
var xFormula = function() {
|
2016-10-18 12:34:19 -04:00
|
|
|
var x = (leftPadding + videoWidth) * column + leftPadding
|
|
|
|
return x
|
|
|
|
}
|
|
|
|
|
|
|
|
// do self first
|
|
|
|
var myVideo = Realtime.localVideo.view
|
|
|
|
if (!myVideo.manuallyPositioned) {
|
|
|
|
myVideo.$container.css({
|
|
|
|
top: yFormula() + 'px',
|
|
|
|
left: xFormula() + 'px'
|
|
|
|
})
|
|
|
|
}
|
2016-11-07 15:25:08 -05:00
|
|
|
videoIds.forEach(function(id) {
|
2016-10-18 12:34:19 -04:00
|
|
|
var video = self.room.videos[id]
|
|
|
|
if (!video.manuallyPositioned) {
|
|
|
|
video.$container.css({
|
|
|
|
top: yFormula() + 'px',
|
|
|
|
left: xFormula() + 'px'
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
2016-11-07 15:25:08 -05:00
|
|
|
callEnded: function() {
|
2016-10-18 12:34:19 -04:00
|
|
|
var self = Realtime
|
|
|
|
|
2016-12-21 03:56:29 -05:00
|
|
|
ChatView.conversationEnded()
|
2016-10-18 12:34:19 -04:00
|
|
|
self.room.leaveVideoOnly()
|
|
|
|
self.inConversation = false
|
|
|
|
self.localVideo.view.$container.hide().css({
|
|
|
|
top: '72px',
|
|
|
|
left: '30px'
|
|
|
|
})
|
|
|
|
self.localVideo.view.audioOn()
|
|
|
|
self.localVideo.view.videoOn()
|
|
|
|
},
|
2016-11-07 15:25:08 -05:00
|
|
|
createCompass: function(name, id, image, color) {
|
2016-10-18 12:34:19 -04:00
|
|
|
var str = '<img width="28" height="28" src="' + image + '" /><p>' + name + '</p>'
|
|
|
|
str += '<div id="compassArrow' + id + '" class="compassArrow"></div>'
|
|
|
|
$('#compass' + id).remove()
|
|
|
|
$('<div/>', {
|
|
|
|
id: 'compass' + id,
|
|
|
|
class: 'collabCompass'
|
|
|
|
}).html(str).appendTo('#wrapper')
|
|
|
|
$('#compass' + id + ' img').css({
|
|
|
|
'border': '2px solid ' + color
|
|
|
|
})
|
|
|
|
$('#compass' + id + ' p').css({
|
|
|
|
'background-color': color
|
|
|
|
})
|
|
|
|
},
|
2016-11-07 15:25:08 -05:00
|
|
|
positionPeerIcons: function() {
|
2016-10-18 12:34:19 -04:00
|
|
|
var self = Realtime
|
|
|
|
for (var key in self.mappersOnMap) {
|
|
|
|
self.positionPeerIcon(key)
|
|
|
|
}
|
|
|
|
},
|
2016-11-07 15:25:08 -05:00
|
|
|
positionPeerIcon: function(id) {
|
2016-10-18 12:34:19 -04:00
|
|
|
var self = Realtime
|
|
|
|
var mapper = self.mappersOnMap[id]
|
|
|
|
|
2016-10-25 12:28:51 +08:00
|
|
|
var origPixels = Util.coordsToPixels(Visualize.mGraph, mapper.coords)
|
2016-10-18 12:34:19 -04:00
|
|
|
var pixels = self.limitPixelsToScreen(origPixels)
|
|
|
|
$('#compass' + id).css({
|
|
|
|
left: pixels.x + 'px',
|
|
|
|
top: pixels.y + 'px'
|
|
|
|
})
|
|
|
|
/* showing the arrow if the collaborator is off of the viewport screen */
|
|
|
|
if (origPixels.x !== pixels.x || origPixels.y !== pixels.y) {
|
|
|
|
var dy = origPixels.y - pixels.y // opposite
|
|
|
|
var dx = origPixels.x - pixels.x // adjacent
|
|
|
|
var angle = Math.atan2(dy, dx)
|
|
|
|
|
|
|
|
$('#compassArrow' + id).show().css({
|
|
|
|
transform: 'rotate(' + angle + 'rad)',
|
2016-11-07 15:25:08 -05:00
|
|
|
'-webkit-transform': 'rotate(' + angle + 'rad)'
|
2016-10-18 12:34:19 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
if (dx > 0) {
|
|
|
|
$('#compass' + id).addClass('labelLeft')
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$('#compassArrow' + id).hide()
|
|
|
|
$('#compass' + id).removeClass('labelLeft')
|
|
|
|
}
|
|
|
|
},
|
2016-11-07 15:25:08 -05:00
|
|
|
limitPixelsToScreen: function(pixels) {
|
2016-10-18 12:34:19 -04:00
|
|
|
var self = Realtime
|
|
|
|
|
|
|
|
var boundary = self.chatOpen ? '#wrapper' : document
|
|
|
|
var xLimit, yLimit
|
|
|
|
var xMax = $(boundary).width()
|
|
|
|
var yMax = $(boundary).height()
|
|
|
|
var compassDiameter = 56
|
|
|
|
var compassArrowSize = 24
|
|
|
|
|
|
|
|
xLimit = Math.max(0 + compassArrowSize, pixels.x)
|
|
|
|
xLimit = Math.min(xLimit, xMax - compassDiameter)
|
|
|
|
yLimit = Math.max(0 + compassArrowSize, pixels.y)
|
|
|
|
yLimit = Math.min(yLimit, yMax - compassDiameter)
|
|
|
|
|
2016-11-07 15:25:08 -05:00
|
|
|
return {x: xLimit, y: yLimit}
|
2016-10-18 12:34:19 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-18 12:56:30 -04:00
|
|
|
const sendables = [
|
2016-11-07 15:25:08 -05:00
|
|
|
['joinMap', joinMap],
|
|
|
|
['leaveMap', leaveMap],
|
|
|
|
['checkForCall', checkForCall],
|
|
|
|
['acceptCall', acceptCall],
|
|
|
|
['denyCall', denyCall],
|
|
|
|
['denyInvite', denyInvite],
|
|
|
|
['inviteToJoin', inviteToJoin],
|
|
|
|
['inviteACall', inviteACall],
|
|
|
|
['joinCall', joinCall],
|
|
|
|
['leaveCall', leaveCall],
|
|
|
|
['sendMapperInfo', sendMapperInfo],
|
|
|
|
['sendCoords', sendCoords],
|
2017-01-03 16:12:58 -05:00
|
|
|
['dragTopic', dragTopic]
|
2016-10-18 12:56:30 -04:00
|
|
|
]
|
|
|
|
sendables.forEach(sendable => {
|
|
|
|
Realtime[sendable[0]] = sendable[1](Realtime)
|
|
|
|
})
|
2016-10-18 12:34:19 -04:00
|
|
|
|
|
|
|
const subscribeToEvents = (Realtime, socket) => {
|
2016-11-07 15:25:08 -05:00
|
|
|
socket.on(JUNTO_UPDATED, juntoUpdated(Realtime))
|
|
|
|
socket.on(INVITED_TO_CALL, invitedToCall(Realtime))
|
|
|
|
socket.on(INVITED_TO_JOIN, invitedToJoin(Realtime))
|
|
|
|
socket.on(CALL_ACCEPTED, callAccepted(Realtime))
|
|
|
|
socket.on(CALL_DENIED, callDenied(Realtime))
|
|
|
|
socket.on(INVITE_DENIED, inviteDenied(Realtime))
|
|
|
|
socket.on(CALL_IN_PROGRESS, callInProgress(Realtime))
|
|
|
|
socket.on(CALL_STARTED, callStarted(Realtime))
|
|
|
|
socket.on(MAPPER_LIST_UPDATED, mapperListUpdated(Realtime))
|
|
|
|
socket.on(MAPPER_JOINED_CALL, mapperJoinedCall(Realtime))
|
|
|
|
socket.on(MAPPER_LEFT_CALL, mapperLeftCall(Realtime))
|
|
|
|
socket.on(PEER_COORDS_UPDATED, peerCoordsUpdated(Realtime))
|
|
|
|
socket.on(NEW_MAPPER, newMapper(Realtime))
|
|
|
|
socket.on(LOST_MAPPER, lostMapper(Realtime))
|
|
|
|
socket.on(TOPIC_DRAGGED, topicDragged(Realtime))
|
2016-10-18 12:34:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export default Realtime
|