osc: sending speed optimization: all static infos (target, address, preArgs) are cached server side to reduce network overhead

This commit is contained in:
jean-emmanuel 2017-04-09 21:52:49 +02:00
parent 3612496693
commit ab281dd534
8 changed files with 123 additions and 54 deletions

View file

@ -1,3 +1,5 @@
var ipc = require('./ipc')
var WidgetManager = function(){
this.widgets = {}
@ -77,6 +79,17 @@ WidgetManager.prototype.addWidget = function(widget) {
widget.widget.abstract = widget
if (widget.container) widget.container[0].abstract = widget
ipc.send('addWidget', {
hash:hash,
data:{
precision: widget.widgetData.precision,
preArgs: widget.widgetData.preArgs,
split: widget.split,
target: widget.widgetData.target,
address: widget.widgetData.address,
}
})
}
WidgetManager.prototype.removeWidget = function(hash) {
@ -89,6 +102,10 @@ WidgetManager.prototype.removeWidget = function(hash) {
if (this.widgets[hash]) {
if (this.widgets[hash].onRemove) this.widgets[hash].onRemove()
delete this.widgets[hash]
ipc.send('removeWidget', {
hash:hash
})
}
if (id && this.idRoute[id].indexOf(hash) != -1) this.idRoute[id].splice(this.idRoute[id].indexOf(hash), 1)
if (linkId && this.linkIdRoute[linkId].indexOf(hash) != -1) this.linkIdRoute[linkId].splice(this.linkIdRoute[linkId].indexOf(hash), 1)

View file

@ -17,7 +17,7 @@ Osc.prototype.send = function(data) {
if (this.syncOnly) {
ipc.send('syncOsc', data)
this.sync(data)
} else {
@ -27,6 +27,12 @@ Osc.prototype.send = function(data) {
}
Osc.prototype.sync = function(data) {
ipc.send('syncOsc', data)
}
Osc.prototype.receive = function(data){
if (this.remoteControl.exists(data.address)) return this.remoteControl.exec(data.address, data.args)

View file

@ -124,15 +124,21 @@ module.exports = class Push extends _widgets_base {
sendValue(v, norelease) {
var args = this.widgetData.preArgs.concat(v)
if (norelease) {
osc.send({
target: this.widgetData.target,
address: this.widgetData.address,
precision: this.widgetData.precision,
args:args,
syncOnly:norelease
})
osc.send({
h: this.hash,
v: this.value
})
} else {
osc.sync({
h: this.hash,
v: this.value
})
}
}

View file

@ -26,31 +26,11 @@ module.exports = class _widgets_base {
sendValue() {
var args = this.widgetData.preArgs.concat(this.value)
osc.send({
target:this.widgetData.target,
address:this.widgetData.address,
precision:this.widgetData.precision,
args:args,
syncOnly:this.split?true:false
h:this.hash,
v:this.value
})
if (this.split) {
var n = 0
for (i in this.split) {
osc.send({
target:this.widgetData.target,
address:this.split[i],
precision:this.widgetData.precision,
args:this.widgetData.preArgs.concat(this.value[n]),
sync:false
})
n++
}
}
}
getValue() {

View file

@ -111,13 +111,9 @@ module.exports = class _switchers_base extends _widgets_base {
sendValue() {
var args = this.widgetData.preArgs.concat(this.value)
osc.send({
target:this.widgetData.target,
address:this.widgetData.address,
args:args,
syncOnly:true
osc.sync({
h:this.hash,
v:this.value
})
}