osc: sending speed optimization: all static infos (target, address, preArgs) are cached server side to reduce network overhead
This commit is contained in:
parent
3612496693
commit
ab281dd534
8 changed files with 123 additions and 54 deletions
|
|
@ -7,7 +7,8 @@ var express = require('express')(),
|
|||
ioWildcard = require('socketio-wildcard')(),
|
||||
ipc = {},
|
||||
settings = require('./settings'),
|
||||
appAddresses = settings.read('appAddresses')
|
||||
appAddresses = settings.read('appAddresses'),
|
||||
clients = {}
|
||||
|
||||
express.get('/', function(req, res){
|
||||
res.sendFile(path.resolve(__dirname + '/../browser/index.html'))
|
||||
|
|
@ -34,21 +35,21 @@ ipc.send = function(name,data,clientId) {
|
|||
|
||||
var bindCallbacks = function(callbacks) {
|
||||
io.on('connection', function(socket) {
|
||||
|
||||
clients[socket.id] = socket
|
||||
|
||||
socket.on('*', function(e){
|
||||
var name = e.data[0],
|
||||
data = e.data[1]
|
||||
|
||||
if ((name=='sendOsc' && data.sync!==false) || name=='syncOsc') {
|
||||
// synchronize all other connected clients
|
||||
socket.broadcast.emit('receiveOsc',data)
|
||||
}
|
||||
if (name=='sessionOpened') {
|
||||
// synchronize all other connected clients
|
||||
socket.broadcast.emit('stateSend',data)
|
||||
}
|
||||
|
||||
if (callbacks[name]) callbacks[name](data,socket.id)
|
||||
})
|
||||
|
||||
socket.on('disconnect', function() {
|
||||
callbacks.removeClientWidgets(socket.id)
|
||||
})
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -58,5 +59,6 @@ console.log('App available at ' + appAddresses.join(' & '))
|
|||
|
||||
module.exports = {
|
||||
ipc:ipc,
|
||||
bindCallbacks:bindCallbacks
|
||||
bindCallbacks:bindCallbacks,
|
||||
clients:clients
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue