added dynamic support

This commit is contained in:
Ashutosh Chaudhary 2017-11-18 03:40:36 +05:30
parent 8fa80e147c
commit 6c93d5a1ac
2 changed files with 26 additions and 0 deletions

View file

@ -35,6 +35,31 @@ export default {
}
})
this.$options.multisockets = new Proxy({}, {
deleteProperty: (target, key) => {
Object.keys(this.$options.multisockets[key]).forEach(item => {
Emitter.removeListener(item, this.$options.multisockets[key][item], this)
})
delete target.key;
return true
}
})
Object.keys(connection).forEach(object => {
this.$options.multisockets[object] = new Proxy({}, {
set: (target, key, value) => {
Emitter.addListener(key, value, this)
target[key] = value
return true;
},
deleteProperty: (target, key) => {
Emitter.removeListener(key, this.$options.multisockets[object][key], this)
delete target.key;
return true
}
})
})
if(sockets){
Object.keys(sockets).forEach((key) => {
this.$options.sockets[key] = sockets[key];

View file

@ -31,6 +31,7 @@ export default class{
onEventWithKey(socket, key){
var super_onevent = socket.onevent;
console.log('super event', super_onevent)
socket.onevent = (packet) => {
super_onevent.call(socket, packet);