Will be redoing the event interface for subscriptions, some work for the wi and crash fixes

This commit is contained in:
KimLS
2017-01-30 23:22:52 -08:00
parent a8699eb40c
commit d5bd773a46
17 changed files with 205 additions and 98 deletions
+9 -3
View File
@@ -113,20 +113,26 @@ class ServertalkAPI
var subs = this.subscriptions[event_id];
if(subs) {
console.log('Subscribe', who.uuid, 'to', event_id);
//console.log('Subscribe', who.uuid, 'to', event_id);
subs[who.uuid] = who;
} else {
console.log('Subscribe', who.uuid, 'to', event_id);
//console.log('Subscribe', who.uuid, 'to', event_id);
this.subscriptions[event_id] = { };
this.subscriptions[event_id][who.uuid] = who;
//Tell our server we have a subscription for event_id
}
}
Unsubscribe(event_id, who) {
var subs = this.subscriptions[event_id];
if(subs) {
console.log('Unsubscribe', who.uuid, 'from', event_id);
//console.log('Unsubscribe', who.uuid, 'from', event_id);
delete subs[who.uuid];
if(Object.keys(subs).length === 0) {
delete this.subscriptions[event_id];
//Tell our server we no longer have a subscription for event_id
}
}
}