make it all work
This commit is contained in:
parent
9ae28866d9
commit
a0efb2cac8
6 changed files with 302 additions and 326 deletions
|
@ -63,7 +63,7 @@ _Backbone.Map = Backbone.Model.extend({
|
||||||
this.on('saved', this.savedEvent)
|
this.on('saved', this.savedEvent)
|
||||||
},
|
},
|
||||||
savedEvent: function () {
|
savedEvent: function () {
|
||||||
Realtime.sendMapChange(this)
|
Realtime.updateMap(this)
|
||||||
},
|
},
|
||||||
authorizeToEdit: function (mapper) {
|
authorizeToEdit: function (mapper) {
|
||||||
if (mapper && (
|
if (mapper && (
|
||||||
|
@ -370,7 +370,7 @@ _Backbone.init = function () {
|
||||||
return node
|
return node
|
||||||
},
|
},
|
||||||
savedEvent: function () {
|
savedEvent: function () {
|
||||||
Realtime.sendTopicChange(this)
|
Realtime.updateTopic(this)
|
||||||
},
|
},
|
||||||
updateViews: function () {
|
updateViews: function () {
|
||||||
var onPageWithTopicCard = Active.Map || Active.Topic
|
var onPageWithTopicCard = Active.Map || Active.Topic
|
||||||
|
@ -549,7 +549,7 @@ _Backbone.init = function () {
|
||||||
return edge
|
return edge
|
||||||
},
|
},
|
||||||
savedEvent: function () {
|
savedEvent: function () {
|
||||||
Realtime.sendSynapseChange(this)
|
Realtime.updateSynapse(this)
|
||||||
},
|
},
|
||||||
updateViews: function () {
|
updateViews: function () {
|
||||||
this.updateCardView()
|
this.updateCardView()
|
||||||
|
|
|
@ -10,7 +10,6 @@ export const INVITE_TO_JOIN = 'INVITE_TO_JOIN'
|
||||||
export const INVITE_A_CALL = 'INVITE_A_CALL'
|
export const INVITE_A_CALL = 'INVITE_A_CALL'
|
||||||
export const JOIN_CALL = 'JOIN_CALL'
|
export const JOIN_CALL = 'JOIN_CALL'
|
||||||
export const LEAVE_CALL = 'LEAVE_CALL'
|
export const LEAVE_CALL = 'LEAVE_CALL'
|
||||||
export const REQUEST_MAPPER_INFO = 'REQUEST_MAPPER_INFO'
|
|
||||||
export const SEND_MAPPER_INFO = 'SEND_MAPPER_INFO'
|
export const SEND_MAPPER_INFO = 'SEND_MAPPER_INFO'
|
||||||
export const SEND_COORDS = 'SEND_COORDS'
|
export const SEND_COORDS = 'SEND_COORDS'
|
||||||
export const CREATE_MESSAGE = 'CREATE_MESSAGE'
|
export const CREATE_MESSAGE = 'CREATE_MESSAGE'
|
||||||
|
@ -53,4 +52,3 @@ export const MAP_UPDATED = 'MAP_UPDATED'
|
||||||
export const LIVE_MAPS_RECEIVED = 'LIVE_MAPS_RECEIVED'
|
export const LIVE_MAPS_RECEIVED = 'LIVE_MAPS_RECEIVED'
|
||||||
export const MAP_WENT_LIVE = 'MAP_WENT_LIVE'
|
export const MAP_WENT_LIVE = 'MAP_WENT_LIVE'
|
||||||
export const MAP_CEASED_LIVE = 'MAP_CEASED_LIVE'
|
export const MAP_CEASED_LIVE = 'MAP_CEASED_LIVE'
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
* - Metamaps.Synapses
|
* - Metamaps.Synapses
|
||||||
* - Metamaps.Topics
|
* - Metamaps.Topics
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import SimpleWebRTC from 'simplewebrtc'
|
import SimpleWebRTC from 'simplewebrtc'
|
||||||
|
|
||||||
|
@ -96,7 +97,6 @@ import {
|
||||||
inviteACall,
|
inviteACall,
|
||||||
joinCall,
|
joinCall,
|
||||||
leaveCall,
|
leaveCall,
|
||||||
requestMapperInfo,
|
|
||||||
sendMapperInfo,
|
sendMapperInfo,
|
||||||
sendCoords,
|
sendCoords,
|
||||||
dragTopic,
|
dragTopic,
|
||||||
|
@ -111,10 +111,6 @@ import {
|
||||||
updateMap
|
updateMap
|
||||||
} from './sendable'
|
} from './sendable'
|
||||||
|
|
||||||
var socketReference = null
|
|
||||||
|
|
||||||
export const getSocket = () => socketReference
|
|
||||||
|
|
||||||
const Realtime = {
|
const Realtime = {
|
||||||
videoId: 'video-wrapper',
|
videoId: 'video-wrapper',
|
||||||
socket: null,
|
socket: null,
|
||||||
|
@ -133,10 +129,13 @@ const Realtime = {
|
||||||
self.addJuntoListeners()
|
self.addJuntoListeners()
|
||||||
|
|
||||||
self.socket = new SocketIoConnection({ url: Metamaps.Erb['REALTIME_SERVER']})
|
self.socket = new SocketIoConnection({ url: Metamaps.Erb['REALTIME_SERVER']})
|
||||||
socketReference = self.socket
|
|
||||||
|
setupSendables(self)
|
||||||
|
|
||||||
self.socket.on('connect', function () {
|
self.socket.on('connect', function () {
|
||||||
console.log('connected')
|
console.log('connected')
|
||||||
subscribeToEvents(self.socket)
|
subscribeToEvents(self, self.socket)
|
||||||
|
|
||||||
if (!self.disconnected) {
|
if (!self.disconnected) {
|
||||||
self.startActiveMap()
|
self.startActiveMap()
|
||||||
} else self.disconnected = false
|
} else self.disconnected = false
|
||||||
|
@ -233,7 +232,7 @@ const Realtime = {
|
||||||
if (Active.Map.authorizeToEdit(Active.Mapper)) {
|
if (Active.Map.authorizeToEdit(Active.Mapper)) {
|
||||||
self.turnOn()
|
self.turnOn()
|
||||||
self.setupSocket()
|
self.setupSocket()
|
||||||
self.setupSendables()
|
self.setupLocalSendables()
|
||||||
}
|
}
|
||||||
self.room.addMessages(new Metamaps.Backbone.MessageCollection(Metamaps.Messages), true)
|
self.room.addMessages(new Metamaps.Backbone.MessageCollection(Metamaps.Messages), true)
|
||||||
}
|
}
|
||||||
|
@ -273,9 +272,9 @@ const Realtime = {
|
||||||
var self = Realtime
|
var self = Realtime
|
||||||
// subscribe to rooms on the websocket?
|
// subscribe to rooms on the websocket?
|
||||||
self.checkForCall()
|
self.checkForCall()
|
||||||
self.newMapperNotify()
|
self.joinMap()
|
||||||
},
|
},
|
||||||
setupSendables: function () {
|
setupLocalSendables: function () {
|
||||||
var self = Realtime
|
var self = Realtime
|
||||||
|
|
||||||
// local event listeners that trigger events
|
// local event listeners that trigger events
|
||||||
|
@ -496,8 +495,11 @@ const Realtime = {
|
||||||
yLimit = Math.min(yLimit, yMax - compassDiameter)
|
yLimit = Math.min(yLimit, yMax - compassDiameter)
|
||||||
|
|
||||||
return {x: xLimit,y: yLimit}
|
return {x: xLimit,y: yLimit}
|
||||||
},
|
}
|
||||||
requestLiveMaps,
|
}
|
||||||
|
|
||||||
|
const setupSendables = Realtime => {
|
||||||
|
[requestLiveMaps,
|
||||||
joinMap,
|
joinMap,
|
||||||
leaveMap,
|
leaveMap,
|
||||||
checkForCall,
|
checkForCall,
|
||||||
|
@ -508,7 +510,6 @@ const Realtime = {
|
||||||
inviteACall,
|
inviteACall,
|
||||||
joinCall,
|
joinCall,
|
||||||
leaveCall,
|
leaveCall,
|
||||||
requestMapperInfo,
|
|
||||||
sendMapperInfo,
|
sendMapperInfo,
|
||||||
sendCoords,
|
sendCoords,
|
||||||
dragTopic,
|
dragTopic,
|
||||||
|
@ -520,67 +521,37 @@ const Realtime = {
|
||||||
updateSynapse,
|
updateSynapse,
|
||||||
removeSynapse,
|
removeSynapse,
|
||||||
deleteSynapse,
|
deleteSynapse,
|
||||||
updateMap
|
updateMap].forEach(sendable => Realtime[sendable.name] = sendable(Realtime, Realtime.socket))
|
||||||
}
|
}
|
||||||
|
|
||||||
const subscribeToEvents = socket => {
|
const subscribeToEvents = (Realtime, socket) => {
|
||||||
socket.on(INVITED_TO_CALL, invitedToCall)
|
socket.on(INVITED_TO_CALL, invitedToCall(Realtime))
|
||||||
socket.on(INVITED_TO_JOIN, invitedToJoin)
|
socket.on(INVITED_TO_JOIN, invitedToJoin(Realtime))
|
||||||
socket.on(CALL_ACCEPTED, callAccepted)
|
socket.on(CALL_ACCEPTED, callAccepted(Realtime))
|
||||||
socket.on(CALL_DENIED, callDenied)
|
socket.on(CALL_DENIED, callDenied(Realtime))
|
||||||
socket.on(INVITE_DENIED, inviteDenied)
|
socket.on(INVITE_DENIED, inviteDenied(Realtime))
|
||||||
socket.on(CALL_IN_PROGRESS, callInProgress)
|
socket.on(CALL_IN_PROGRESS, callInProgress(Realtime))
|
||||||
socket.on(CALL_STARTED, callStarted)
|
socket.on(CALL_STARTED, callStarted(Realtime))
|
||||||
socket.on(MAPPER_JOINED_CALL, mapperJoinedCall)
|
socket.on(MAPPER_JOINED_CALL, mapperJoinedCall(Realtime))
|
||||||
socket.on(MAPPER_LEFT_CALL, mapperLeftCall)
|
socket.on(MAPPER_LEFT_CALL, mapperLeftCall(Realtime))
|
||||||
socket.on(MAPPER_LIST_UPDATED, mapperListUpdated)
|
socket.on(MAPPER_LIST_UPDATED, mapperListUpdated(Realtime))
|
||||||
socket.on(PEER_COORDS_UPDATED, peerCoordsUpdated)
|
socket.on(PEER_COORDS_UPDATED, peerCoordsUpdated(Realtime))
|
||||||
socket.on(NEW_MAPPER, newMapper)
|
socket.on(NEW_MAPPER, newMapper(Realtime))
|
||||||
socket.on(LOST_MAPPER, lostMapper)
|
socket.on(LOST_MAPPER, lostMapper(Realtime))
|
||||||
socket.on(MESSAGE_CREATED, messageCreated)
|
socket.on(MESSAGE_CREATED, messageCreated(Realtime))
|
||||||
socket.on(TOPIC_DRAGGED, topicDragged)
|
socket.on(TOPIC_DRAGGED, topicDragged(Realtime))
|
||||||
socket.on(TOPIC_CREATED, topicCreated)
|
socket.on(TOPIC_CREATED, topicCreated(Realtime))
|
||||||
socket.on(TOPIC_UPDATED, topicUpdated)
|
socket.on(TOPIC_UPDATED, topicUpdated(Realtime))
|
||||||
socket.on(TOPIC_REMOVED, topicRemoved)
|
socket.on(TOPIC_REMOVED, topicRemoved(Realtime))
|
||||||
socket.on(TOPIC_DELETED, topicDeleted)
|
socket.on(TOPIC_DELETED, topicDeleted(Realtime))
|
||||||
socket.on(SYNAPSE_CREATED, synapseCreated)
|
socket.on(SYNAPSE_CREATED, synapseCreated(Realtime))
|
||||||
socket.on(SYNAPSE_UPDATED, synapseUpdated)
|
socket.on(SYNAPSE_UPDATED, synapseUpdated(Realtime))
|
||||||
socket.on(SYNAPSE_REMOVED, synapseRemoved)
|
socket.on(SYNAPSE_REMOVED, synapseRemoved(Realtime))
|
||||||
socket.on(SYNAPSE_DELETED, synapseDeleted)
|
socket.on(SYNAPSE_DELETED, synapseDeleted(Realtime))
|
||||||
socket.on(MAP_UPDATED, mapUpdated)
|
socket.on(MAP_UPDATED, mapUpdated(Realtime))
|
||||||
socket.on(LIVE_MAPS_RECEIVED, liveMapsReceived)
|
socket.on(LIVE_MAPS_RECEIVED, liveMapsReceived(Realtime))
|
||||||
socket.on(MAP_WENT_LIVE, mapWentLive)
|
socket.on(MAP_WENT_LIVE, mapWentLive(Realtime))
|
||||||
socket.on(MAP_CEASED_LIVE, mapCeasedLive)
|
socket.on(MAP_CEASED_LIVE, mapCeasedLive(Realtime))
|
||||||
}
|
|
||||||
|
|
||||||
const unsub = socket => {
|
|
||||||
socket.off(INVITED_TO_CALL)
|
|
||||||
socket.off(INVITED_TO_JOIN)
|
|
||||||
socket.off(CALL_ACCEPTED)
|
|
||||||
socket.off(CALL_DENIED)
|
|
||||||
socket.off(INVITE_DENIED)
|
|
||||||
socket.off(CALL_IN_PROGRESS)
|
|
||||||
socket.off(CALL_STARTED)
|
|
||||||
socket.off(MAPPER_JOINED_CALL)
|
|
||||||
socket.off(MAPPER_LEFT_CALL)
|
|
||||||
socket.off(MAPPER_LIST_UPDATED)
|
|
||||||
socket.off(PEER_COORDS_UPDATED)
|
|
||||||
socket.off(NEW_MAPPER)
|
|
||||||
socket.off(LOST_MAPPER)
|
|
||||||
socket.off(MESSAGE_CREATED)
|
|
||||||
socket.off(TOPIC_DRAGGED)
|
|
||||||
socket.off(TOPIC_CREATED)
|
|
||||||
socket.off(TOPIC_UPDATED)
|
|
||||||
socket.off(TOPIC_REMOVED)
|
|
||||||
socket.off(TOPIC_DELETED)
|
|
||||||
socket.off(SYNAPSE_CREATED)
|
|
||||||
socket.off(SYNAPSE_UPDATED)
|
|
||||||
socket.off(SYNAPSE_REMOVED)
|
|
||||||
socket.off(SYNAPSE_DELETED)
|
|
||||||
socket.off(MAP_UPDATED)
|
|
||||||
socket.off(LIVE_MAPS_RECEIVED)
|
|
||||||
socket.off(MAP_WENT_LIVE)
|
|
||||||
socket.off(MAP_CEASED_LIVE)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Realtime
|
export default Realtime
|
||||||
|
|
|
@ -7,10 +7,12 @@ import GlobalUI from '../GlobalUI'
|
||||||
import Control from '../Control'
|
import Control from '../Control'
|
||||||
import Map from '../Map'
|
import Map from '../Map'
|
||||||
import Mapper from '../Mapper'
|
import Mapper from '../Mapper'
|
||||||
import Realtime from './index'
|
import Topic from '../Topic'
|
||||||
var self = Realtime
|
import Synapse from '../Synapse'
|
||||||
|
import Util from '../Util'
|
||||||
|
import Visualize from '../Visualize'
|
||||||
|
|
||||||
export const synapseRemoved = data => {
|
export const synapseRemoved = self => data => {
|
||||||
var synapse = Metamaps.Synapses.get(data.mappableid)
|
var synapse = Metamaps.Synapses.get(data.mappableid)
|
||||||
if (synapse) {
|
if (synapse) {
|
||||||
var edge = synapse.get('edge')
|
var edge = synapse.get('edge')
|
||||||
|
@ -30,11 +32,11 @@ export const synapseRemoved = data => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const synapseDeleted = data => {
|
export const synapseDeleted = self => data => {
|
||||||
self.synapseRemoved(data)
|
self.synapseRemoved(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const synapseCreated = function (data) {
|
export const synapseCreated = self => data => {
|
||||||
var topic1, topic2, node1, node2, synapse, mapping, cancel, mapper
|
var topic1, topic2, node1, node2, synapse, mapping, cancel, mapper
|
||||||
|
|
||||||
|
|
||||||
|
@ -82,7 +84,7 @@ export const synapseCreated = function (data) {
|
||||||
waitThenRenderSynapse()
|
waitThenRenderSynapse()
|
||||||
}
|
}
|
||||||
|
|
||||||
export const topicRemoved = function (data) {
|
export const topicRemoved = self => data => {
|
||||||
var topic = Metamaps.Topics.get(data.mappableid)
|
var topic = Metamaps.Topics.get(data.mappableid)
|
||||||
if (topic) {
|
if (topic) {
|
||||||
var node = topic.get('node')
|
var node = topic.get('node')
|
||||||
|
@ -93,11 +95,11 @@ export const topicRemoved = function (data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const topicDeleted = function (data) {
|
export const topicDeleted = self => data => {
|
||||||
self.topicRemoved(data)
|
self.topicRemoved(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const topicCreated = function (data) {
|
export const topicCreated = self => data => {
|
||||||
var topic, mapping, mapper, cancel
|
var topic, mapping, mapper, cancel
|
||||||
|
|
||||||
function waitThenRenderTopic () {
|
function waitThenRenderTopic () {
|
||||||
|
@ -140,11 +142,11 @@ export const topicCreated = function (data) {
|
||||||
waitThenRenderTopic()
|
waitThenRenderTopic()
|
||||||
}
|
}
|
||||||
|
|
||||||
export const messageCreated = function (data) {
|
export const messageCreated = self => data => {
|
||||||
self.room.addMessages(new Metamaps.Backbone.MessageCollection(data))
|
self.room.addMessages(new Metamaps.Backbone.MessageCollection(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
export const mapUpdated = function (data) {
|
export const mapUpdated = self => data => {
|
||||||
var map = Active.Map
|
var map = Active.Map
|
||||||
var isActiveMap = map && data.mapId === map.id
|
var isActiveMap = map && data.mapId === map.id
|
||||||
if (isActiveMap) {
|
if (isActiveMap) {
|
||||||
|
@ -170,7 +172,7 @@ export const mapUpdated = function (data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const topicUpdated = function (data) {
|
export const topicUpdated = self => data => {
|
||||||
var topic = Metamaps.Topics.get(data.topicId)
|
var topic = Metamaps.Topics.get(data.topicId)
|
||||||
if (topic) {
|
if (topic) {
|
||||||
var node = topic.get('node')
|
var node = topic.get('node')
|
||||||
|
@ -183,7 +185,7 @@ export const topicUpdated = function (data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const synapseUpdated = function (data) {
|
export const synapseUpdated = self => data => {
|
||||||
var synapse = Metamaps.Synapses.get(data.synapseId)
|
var synapse = Metamaps.Synapses.get(data.synapseId)
|
||||||
if (synapse) {
|
if (synapse) {
|
||||||
// edge reset necessary because fetch causes model reset
|
// edge reset necessary because fetch causes model reset
|
||||||
|
@ -197,7 +199,7 @@ export const synapseUpdated = function (data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const topicDragged = function (positions) {
|
export const topicDragged = self => positions => {
|
||||||
var topic
|
var topic
|
||||||
var node
|
var node
|
||||||
|
|
||||||
|
@ -211,13 +213,13 @@ export const topicDragged = function (positions) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const peerCoordsUpdated = function (data) {
|
export const peerCoordsUpdated = self => data => {
|
||||||
if (!self.mappersOnMap[data.userid]) return
|
if (!self.mappersOnMap[data.userid]) return
|
||||||
self.mappersOnMap[data.userid].coords = {x: data.usercoords.x,y: data.usercoords.y}
|
self.mappersOnMap[data.userid].coords = {x: data.usercoords.x,y: data.usercoords.y}
|
||||||
self.positionPeerIcon(data.userid)
|
self.positionPeerIcon(data.userid)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const lostMapper = function (data) {
|
export const lostMapper = self => data => {
|
||||||
// data.userid
|
// data.userid
|
||||||
// data.username
|
// data.username
|
||||||
delete self.mappersOnMap[data.userid]
|
delete self.mappersOnMap[data.userid]
|
||||||
|
@ -234,7 +236,7 @@ export const lostMapper = function (data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const mapperListUpdated = function (data) {
|
export const mapperListUpdated = self => data => {
|
||||||
// data.userid
|
// data.userid
|
||||||
// data.username
|
// data.username
|
||||||
// data.userimage
|
// data.userimage
|
||||||
|
@ -261,7 +263,7 @@ export const mapperListUpdated = function (data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const newMapper = function (data) {
|
export const newMapper = self => data => {
|
||||||
// data.userid
|
// data.userid
|
||||||
// data.username
|
// data.username
|
||||||
// data.userimage
|
// data.userimage
|
||||||
|
@ -298,26 +300,26 @@ export const newMapper = function (data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const callAccepted = function (userid) {
|
export const callAccepted = self => userid => {
|
||||||
var username = self.mappersOnMap[userid].name
|
var username = self.mappersOnMap[userid].name
|
||||||
GlobalUI.notifyUser('Conversation starting...')
|
GlobalUI.notifyUser('Conversation starting...')
|
||||||
self.joinCall()
|
self.joinCall()
|
||||||
self.room.chat.invitationAnswered(userid)
|
self.room.chat.invitationAnswered(userid)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const callDenied = function (userid) {
|
export const callDenied = self => userid => {
|
||||||
var username = self.mappersOnMap[userid].name
|
var username = self.mappersOnMap[userid].name
|
||||||
GlobalUI.notifyUser(username + " didn't accept your invitation")
|
GlobalUI.notifyUser(username + " didn't accept your invitation")
|
||||||
self.room.chat.invitationAnswered(userid)
|
self.room.chat.invitationAnswered(userid)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const inviteDenied = function (userid) {
|
export const inviteDenied = self => userid => {
|
||||||
var username = self.mappersOnMap[userid].name
|
var username = self.mappersOnMap[userid].name
|
||||||
GlobalUI.notifyUser(username + " didn't accept your invitation")
|
GlobalUI.notifyUser(username + " didn't accept your invitation")
|
||||||
self.room.chat.invitationAnswered(userid)
|
self.room.chat.invitationAnswered(userid)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const invitedToCall = function (inviter) {
|
export const invitedToCall = self => inviter => {
|
||||||
self.room.chat.sound.stop(self.soundId)
|
self.room.chat.sound.stop(self.soundId)
|
||||||
self.soundId = self.room.chat.sound.play('sessioninvite')
|
self.soundId = self.room.chat.sound.play('sessioninvite')
|
||||||
|
|
||||||
|
@ -329,7 +331,7 @@ export const invitedToCall = function (inviter) {
|
||||||
GlobalUI.notifyUser(notifyText, true)
|
GlobalUI.notifyUser(notifyText, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const invitedToJoin = function (inviter) {
|
export const invitedToJoin = self => inviter => {
|
||||||
self.room.chat.sound.stop(self.soundId)
|
self.room.chat.sound.stop(self.soundId)
|
||||||
self.soundId = self.room.chat.sound.play('sessioninvite')
|
self.soundId = self.room.chat.sound.play('sessioninvite')
|
||||||
|
|
||||||
|
@ -340,7 +342,7 @@ export const invitedToJoin = function (inviter) {
|
||||||
GlobalUI.notifyUser(notifyText, true)
|
GlobalUI.notifyUser(notifyText, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const mapperJoinedCall = function (id) {
|
export const mapperJoinedCall = self => id => {
|
||||||
var mapper = self.mappersOnMap[id]
|
var mapper = self.mappersOnMap[id]
|
||||||
|
|
||||||
if (mapper) {
|
if (mapper) {
|
||||||
|
@ -355,7 +357,7 @@ export const mapperJoinedCall = function (id) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const mapperLeftCall = function (id) {
|
export const mapperLeftCall = self => id => {
|
||||||
var mapper = self.mappersOnMap[id]
|
var mapper = self.mappersOnMap[id]
|
||||||
if (mapper) {
|
if (mapper) {
|
||||||
if (self.inConversation) {
|
if (self.inConversation) {
|
||||||
|
@ -372,7 +374,7 @@ export const mapperLeftCall = function (id) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const callInProgress = function () {
|
export const callInProgress = self => () => {
|
||||||
var notifyText = "There's a conversation happening, want to join?"
|
var notifyText = "There's a conversation happening, want to join?"
|
||||||
notifyText += ' <button type="button" class="toast-button button" onclick="Metamaps.Realtime.joinCall()">Yes</button>'
|
notifyText += ' <button type="button" class="toast-button button" onclick="Metamaps.Realtime.joinCall()">Yes</button>'
|
||||||
notifyText += ' <button type="button" class="toast-button button btn-no" onclick="Metamaps.GlobalUI.clearNotify()">No</button>'
|
notifyText += ' <button type="button" class="toast-button button btn-no" onclick="Metamaps.GlobalUI.clearNotify()">No</button>'
|
||||||
|
@ -380,7 +382,7 @@ export const callInProgress = function () {
|
||||||
self.room.conversationInProgress()
|
self.room.conversationInProgress()
|
||||||
}
|
}
|
||||||
|
|
||||||
export const callStarted = function () {
|
export const callStarted = self => () => {
|
||||||
if (self.inConversation) return
|
if (self.inConversation) return
|
||||||
var notifyText = "There's a conversation starting, want to join?"
|
var notifyText = "There's a conversation starting, want to join?"
|
||||||
notifyText += ' <button type="button" class="toast-button button" onclick="Metamaps.Realtime.joinCall()">Yes</button>'
|
notifyText += ' <button type="button" class="toast-button button" onclick="Metamaps.Realtime.joinCall()">Yes</button>'
|
||||||
|
@ -389,3 +391,6 @@ export const callStarted = function () {
|
||||||
self.room.conversationInProgress()
|
self.room.conversationInProgress()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const liveMapsReceived = self => () => {}
|
||||||
|
export const mapWentLive = self => () => {}
|
||||||
|
export const mapCeasedLive = self => () => {}
|
||||||
|
|
|
@ -13,7 +13,6 @@ import {
|
||||||
INVITE_A_CALL,
|
INVITE_A_CALL,
|
||||||
JOIN_CALL,
|
JOIN_CALL,
|
||||||
LEAVE_CALL,
|
LEAVE_CALL,
|
||||||
REQUEST_MAPPER_INFO,
|
|
||||||
SEND_MAPPER_INFO,
|
SEND_MAPPER_INFO,
|
||||||
SEND_COORDS,
|
SEND_COORDS,
|
||||||
CREATE_MESSAGE,
|
CREATE_MESSAGE,
|
||||||
|
@ -29,16 +28,12 @@ import {
|
||||||
UPDATE_MAP
|
UPDATE_MAP
|
||||||
} from './events'
|
} from './events'
|
||||||
|
|
||||||
export const requestLiveMaps = function (self, socket) {
|
export const requestLiveMaps = (self, socket) => () => {
|
||||||
socket.emit(REQUEST_LIVE_MAPS)
|
socket.emit(REQUEST_LIVE_MAPS)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const checkForCall = function (self, socket) {
|
export const joinMap = (self, socket) => () => {
|
||||||
socket.emit(CHECK_FOR_CALL, { room: self.room.room, mapid: Active.Map.id })
|
socket.emit(JOIN_MAP, {
|
||||||
}
|
|
||||||
|
|
||||||
export const newMapperNotify = function (self, socket) {
|
|
||||||
socket.emit(NEW_MAPPER_NOTIFY, {
|
|
||||||
userid: Active.Mapper.id,
|
userid: Active.Mapper.id,
|
||||||
username: Active.Mapper.get('name'),
|
username: Active.Mapper.get('name'),
|
||||||
userimage: Active.Mapper.get('image'),
|
userimage: Active.Mapper.get('image'),
|
||||||
|
@ -47,7 +42,15 @@ export const newMapperNotify = function (self, socket) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const sendMapperInfo = (userid, self, socket) => {
|
export const leaveMap = (self, socket) => () => {
|
||||||
|
socket.emit(LEAVE_MAP)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const checkForCall = (self, socket) => () => {
|
||||||
|
socket.emit(CHECK_FOR_CALL, { room: self.room.room, mapid: Active.Map.id })
|
||||||
|
}
|
||||||
|
|
||||||
|
export const sendMapperInfo = (self, socket) => userid => {
|
||||||
// send this new mapper back your details, and the awareness that you've loaded the map
|
// send this new mapper back your details, and the awareness that you've loaded the map
|
||||||
var update = {
|
var update = {
|
||||||
userToNotify: userid,
|
userToNotify: userid,
|
||||||
|
@ -60,7 +63,7 @@ export const sendMapperInfo = (userid, self, socket) => {
|
||||||
socket.emit(SEND_MAPPER_INFO, update)
|
socket.emit(SEND_MAPPER_INFO, update)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const joinCall = function (self, socket) {
|
export const joinCall = (self, socket) => () => {
|
||||||
self.webrtc.off('readyToCall')
|
self.webrtc.off('readyToCall')
|
||||||
self.webrtc.once('readyToCall', function () {
|
self.webrtc.once('readyToCall', function () {
|
||||||
self.videoInitialized = true
|
self.videoInitialized = true
|
||||||
|
@ -83,7 +86,7 @@ export const joinCall = function (self, socket) {
|
||||||
self.room.chat.mapperJoinedCall(Active.Mapper.id)
|
self.room.chat.mapperJoinedCall(Active.Mapper.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const leaveCall = function (self, socket) {
|
export const leaveCall = (self, socket) => () => {
|
||||||
socket.emit(LEAVE_CALL, {
|
socket.emit(LEAVE_CALL, {
|
||||||
mapid: Active.Map.id,
|
mapid: Active.Map.id,
|
||||||
id: Active.Mapper.id
|
id: Active.Mapper.id
|
||||||
|
@ -102,7 +105,6 @@ export const leaveCall = function (self, socket) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const acceptCall = (self, socket) => userid => {
|
export const acceptCall = (self, socket) => userid => {
|
||||||
var self = Realtime
|
|
||||||
self.room.chat.sound.stop(self.soundId)
|
self.room.chat.sound.stop(self.soundId)
|
||||||
socket.emit(ACCEPT_CALL, {
|
socket.emit(ACCEPT_CALL, {
|
||||||
mapid: Active.Map.id,
|
mapid: Active.Map.id,
|
||||||
|
@ -114,7 +116,7 @@ export const acceptCall = (self, socket) => userid => {
|
||||||
GlobalUI.clearNotify()
|
GlobalUI.clearNotify()
|
||||||
}
|
}
|
||||||
|
|
||||||
export const denyCall = (userid) => {
|
export const denyCall = (self, socket) => userid => {
|
||||||
self.room.chat.sound.stop(self.soundId)
|
self.room.chat.sound.stop(self.soundId)
|
||||||
socket.emit(DENY_CALL, {
|
socket.emit(DENY_CALL, {
|
||||||
mapid: Active.Map.id,
|
mapid: Active.Map.id,
|
||||||
|
@ -124,7 +126,7 @@ export const denyCall = (userid) => {
|
||||||
GlobalUI.clearNotify()
|
GlobalUI.clearNotify()
|
||||||
}
|
}
|
||||||
|
|
||||||
export const denyInvite = (userid) => {
|
export const denyInvite = (self, socket) => userid => {
|
||||||
self.room.chat.sound.stop(self.soundId)
|
self.room.chat.sound.stop(self.soundId)
|
||||||
socket.emit(DENY_INVITE, {
|
socket.emit(DENY_INVITE, {
|
||||||
mapid: Active.Map.id,
|
mapid: Active.Map.id,
|
||||||
|
@ -134,7 +136,7 @@ export const denyInvite = (userid) => {
|
||||||
GlobalUI.clearNotify()
|
GlobalUI.clearNotify()
|
||||||
}
|
}
|
||||||
|
|
||||||
export const inviteACall = function (userid) {
|
export const inviteACall = (self, socket) => userid => {
|
||||||
socket.emit(INVITE_A_CALL, {
|
socket.emit(INVITE_A_CALL, {
|
||||||
mapid: Active.Map.id,
|
mapid: Active.Map.id,
|
||||||
inviter: Active.Mapper.id,
|
inviter: Active.Mapper.id,
|
||||||
|
@ -144,7 +146,7 @@ export const inviteACall = function (userid) {
|
||||||
GlobalUI.clearNotify()
|
GlobalUI.clearNotify()
|
||||||
}
|
}
|
||||||
|
|
||||||
export const inviteToJoin = function (userid) {
|
export const inviteToJoin = (self, socket) => userid => {
|
||||||
socket.emit(INVITE_TO_JOIN, {
|
socket.emit(INVITE_TO_JOIN, {
|
||||||
mapid: Active.Map.id,
|
mapid: Active.Map.id,
|
||||||
inviter: Active.Mapper.id,
|
inviter: Active.Mapper.id,
|
||||||
|
@ -153,7 +155,7 @@ export const inviteToJoin = function (userid) {
|
||||||
self.room.chat.invitationPending(userid)
|
self.room.chat.invitationPending(userid)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const sendCoords = function (coords) {
|
export const sendCoords = (self, socket) => coords => {
|
||||||
var map = Active.Map
|
var map = Active.Map
|
||||||
var mapper = Active.Mapper
|
var mapper = Active.Mapper
|
||||||
if (map.authorizeToEdit(mapper)) {
|
if (map.authorizeToEdit(mapper)) {
|
||||||
|
@ -166,41 +168,41 @@ export const sendCoords = function (coords) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const dragTopic = function (positions) {
|
export const dragTopic = (self, socket) => positions => {
|
||||||
if (Active.Map) {
|
if (Active.Map) {
|
||||||
positions.mapid = Active.Map.id
|
positions.mapid = Active.Map.id
|
||||||
socket.emit(DRAG_TOPIC, positions)
|
socket.emit(DRAG_TOPIC, positions)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const updateTopic = function (topic) {
|
export const updateTopic = (self, socket) => topic => {
|
||||||
var data = {
|
var data = {
|
||||||
topicId: topic.id
|
topicId: topic.id
|
||||||
}
|
}
|
||||||
socket.emit(UPDATE_TOPIC, data)
|
socket.emit(UPDATE_TOPIC, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const updateSynapse = function (synapse) {
|
export const updateSynapse = (self, socket) => synapse => {
|
||||||
var data = {
|
var data = {
|
||||||
synapseId: synapse.id
|
synapseId: synapse.id
|
||||||
}
|
}
|
||||||
socket.emit(UPDATE_SYNAPSE, data)
|
socket.emit(UPDATE_SYNAPSE, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const updateMap = function (map) {
|
export const updateMap = (self, socket) => map => {
|
||||||
var data = {
|
var data = {
|
||||||
mapId: map.id
|
mapId: map.id
|
||||||
}
|
}
|
||||||
socket.emit(UPDATE_MAP, data)
|
socket.emit(UPDATE_MAP, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createMessage = function (data) {
|
export const createMessage = (self, socket) => data => {
|
||||||
var message = data.attributes
|
var message = data.attributes
|
||||||
message.mapid = Active.Map.id
|
message.mapid = Active.Map.id
|
||||||
socket.emit(CREATE_MESSAGE, message)
|
socket.emit(CREATE_MESSAGE, message)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createTopic = function (data) {
|
export const createTopic = (self, socket) => data => {
|
||||||
if (Active.Map) {
|
if (Active.Map) {
|
||||||
data.mapperid = Active.Mapper.id
|
data.mapperid = Active.Mapper.id
|
||||||
data.mapid = Active.Map.id
|
data.mapid = Active.Map.id
|
||||||
|
@ -208,20 +210,20 @@ export const createTopic = function (data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const deleteTopic = function (data) {
|
export const deleteTopic = (self, socket) => data => {
|
||||||
if (Active.Map) {
|
if (Active.Map) {
|
||||||
socket.emit(DELETE_TOPIC, data)
|
socket.emit(DELETE_TOPIC, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const removeTopic = function (data) {
|
export const removeTopic = (self, socket) => data => {
|
||||||
if (Active.Map) {
|
if (Active.Map) {
|
||||||
data.mapid = Active.Map.id
|
data.mapid = Active.Map.id
|
||||||
socket.emit(REMOVE_TOPIC, data)
|
socket.emit(REMOVE_TOPIC, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createSynapse = function (data) {
|
export const createSynapse = (self, socket) => data => {
|
||||||
if (Active.Map) {
|
if (Active.Map) {
|
||||||
data.mapperid = Active.Mapper.id
|
data.mapperid = Active.Mapper.id
|
||||||
data.mapid = Active.Map.id
|
data.mapid = Active.Map.id
|
||||||
|
@ -229,14 +231,14 @@ export const createSynapse = function (data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const deleteSynapse = function (data) {
|
export const deleteSynapse = (self, socket) => data => {
|
||||||
if (Active.Map) {
|
if (Active.Map) {
|
||||||
data.mapid = Active.Map.id
|
data.mapid = Active.Map.id
|
||||||
socket.emit(DELETE_SYNAPSE, data)
|
socket.emit(DELETE_SYNAPSE, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const removeSynapse = function (data) {
|
export const removeSynapse = (self, socket) => data => {
|
||||||
if (Active.Map) {
|
if (Active.Map) {
|
||||||
data.mapid = Active.Map.id
|
data.mapid = Active.Map.id
|
||||||
socket.emit(REMOVE_SYNAPSE, data)
|
socket.emit(REMOVE_SYNAPSE, data)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
var
|
var
|
||||||
io = require('socket.io').listen(5001),
|
io = require('socket.io').listen(5001),
|
||||||
signalServer = require('./signal'),
|
signalServer = require('./signal'),
|
||||||
stunservers = [{"url": "stun:stun.l.google.com:19302"}]
|
stunservers = [{"url": "stun:stun.l.google.com:19302"}]
|
||||||
|
|
||||||
import {
|
import {
|
||||||
// server sendable, client receivable
|
// server sendable, client receivable
|
||||||
|
@ -134,7 +134,7 @@ function start() {
|
||||||
})
|
})
|
||||||
|
|
||||||
// this will ping everyone on a map that there's a person just joined the map
|
// this will ping everyone on a map that there's a person just joined the map
|
||||||
socket.on(NEW_MAPPER, function (data) {
|
socket.on(JOIN_MAP, function (data) {
|
||||||
|
|
||||||
if (!livemaps[data.mapid]) {
|
if (!livemaps[data.mapid]) {
|
||||||
livemaps[data.mapid] = data.map // { name: '', desc: '', numTopics: '' }
|
livemaps[data.mapid] = data.map // { name: '', desc: '', numTopics: '' }
|
||||||
|
@ -186,7 +186,7 @@ function start() {
|
||||||
}
|
}
|
||||||
// this will ping everyone on a map that there's a person just left the map
|
// this will ping everyone on a map that there's a person just left the map
|
||||||
socket.on('disconnect', end)
|
socket.on('disconnect', end)
|
||||||
socket.on('endMapperNotify', end)
|
socket.on(LEAVE_MAP, end)
|
||||||
|
|
||||||
socket.on(SEND_COORDS, function (data) {
|
socket.on(SEND_COORDS, function (data) {
|
||||||
var peer = {
|
var peer = {
|
||||||
|
@ -217,7 +217,7 @@ function start() {
|
||||||
var mapId = data.mapid
|
var mapId = data.mapid
|
||||||
delete data.mapid
|
delete data.mapid
|
||||||
//socket.broadcast.emit('maps-' + mapId + '-newTopic', data)
|
//socket.broadcast.emit('maps-' + mapId + '-newTopic', data)
|
||||||
socket.broadbast.emit(TOPIC_CREATED, data)
|
socket.broadcast.emit(TOPIC_CREATED, data)
|
||||||
})
|
})
|
||||||
|
|
||||||
socket.on(UPDATE_TOPIC, function (data) {
|
socket.on(UPDATE_TOPIC, function (data) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue