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
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
})
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue