better widget hash (+ deps: shortid); re-registers widgets on reconnection
This commit is contained in:
parent
ab281dd534
commit
0f737bcedf
5 changed files with 22 additions and 4 deletions
|
|
@ -206,7 +206,7 @@ module.exports = {
|
|||
|
||||
removeWidget(data, clientId) {
|
||||
|
||||
delete widgetHashTable[data.hash + clientId]
|
||||
delete widgetHashTable[clientId][data.hash]
|
||||
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,9 @@ var bindCallbacks = function(callbacks) {
|
|||
})
|
||||
|
||||
socket.on('disconnect', function() {
|
||||
|
||||
callbacks.removeClientWidgets(socket.id)
|
||||
|
||||
})
|
||||
|
||||
})
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
"node-sass": "^4.1.1",
|
||||
"nodemon": "^1.9.2",
|
||||
"socket.io-client": "1.7.3",
|
||||
"shortid": "2.2.8",
|
||||
"electron-installer-debian": "0.5.0",
|
||||
"electron-packager": "8.6.0"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue