Merge branch '514-cmb-refactor-realtime-map' into '488-cmb-live'
Change mqtt session to persistent #514 See merge request jankstudio/resq!596
This commit is contained in:
commit
adadb611b8
1 changed files with 9 additions and 1 deletions
|
|
@ -3,6 +3,7 @@ class MapEventHandler {
|
|||
this.options = options;
|
||||
this.dashmap = dashmap;
|
||||
this.ssl = ssl;
|
||||
this.subscribed = false;
|
||||
}
|
||||
|
||||
connect(user_id, host, port) {
|
||||
|
|
@ -21,7 +22,8 @@ class MapEventHandler {
|
|||
keepAliveInterval: 10,
|
||||
invocationContext: this,
|
||||
onSuccess: this.onConnect.bind(this),
|
||||
reconnect: true
|
||||
reconnect: true,
|
||||
cleanSession: false
|
||||
};
|
||||
|
||||
this.mqtt.onMessageArrived = this.onMessage.bind(this);
|
||||
|
|
@ -40,6 +42,11 @@ class MapEventHandler {
|
|||
console.log('mqtt connected!');
|
||||
var my = icontext.invocationContext;
|
||||
|
||||
if (my.subscribed) {
|
||||
console.log('already subscribed, not initializing subscriptions');
|
||||
return;
|
||||
}
|
||||
|
||||
if (my.options.track_rider) {
|
||||
// subscribe to rider locations
|
||||
console.log('subscribing to ' + my.options.channels.rider_location);
|
||||
|
|
@ -68,6 +75,7 @@ class MapEventHandler {
|
|||
my.mqtt.subscribe(my.options.channels.jo_origin);
|
||||
}
|
||||
|
||||
my.subscribed = true;
|
||||
}
|
||||
|
||||
onMessage(msg) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue