better widget hash (+ deps: shortid); re-registers widgets on reconnection

This commit is contained in:
jean-emmanuel 2017-04-09 23:09:00 +02:00
parent ab281dd534
commit 0f737bcedf
5 changed files with 22 additions and 4 deletions

View file

@ -41,6 +41,21 @@ var WidgetManager = function(){
})
})
ipc.socket.on('reconnect', ()=>{
for (var hash in this.widgets) {
ipc.send('addWidget', {
hash:hash,
data:{
precision: this.widgets[hash].widgetData.precision,
preArgs: this.widgets[hash].widgetData.preArgs,
split: this.widgets[hash].split,
target: this.widgets[hash].widgetData.target,
address: this.widgets[hash].widgetData.address,
}
})
}
})
}

View file

@ -1,4 +1,5 @@
var osc = require('../../osc')
var osc = require('../../osc'),
shortid = require('shortid')
module.exports = class _widgets_base {
@ -10,8 +11,7 @@ module.exports = class _widgets_base {
static createHash() {
return String(Math.random()).split("").reduce(function(a,b){a=((a<<5)-a)+b.charCodeAt(0);return a&a},0);
return shortid.generate()
}
constructor(widgetData, widgetContainer, widgetHtml) {