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.options = options;
|
||||||
this.dashmap = dashmap;
|
this.dashmap = dashmap;
|
||||||
this.ssl = ssl;
|
this.ssl = ssl;
|
||||||
|
this.subscribed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(user_id, host, port) {
|
connect(user_id, host, port) {
|
||||||
|
|
@ -21,7 +22,8 @@ class MapEventHandler {
|
||||||
keepAliveInterval: 10,
|
keepAliveInterval: 10,
|
||||||
invocationContext: this,
|
invocationContext: this,
|
||||||
onSuccess: this.onConnect.bind(this),
|
onSuccess: this.onConnect.bind(this),
|
||||||
reconnect: true
|
reconnect: true,
|
||||||
|
cleanSession: false
|
||||||
};
|
};
|
||||||
|
|
||||||
this.mqtt.onMessageArrived = this.onMessage.bind(this);
|
this.mqtt.onMessageArrived = this.onMessage.bind(this);
|
||||||
|
|
@ -40,6 +42,11 @@ class MapEventHandler {
|
||||||
console.log('mqtt connected!');
|
console.log('mqtt connected!');
|
||||||
var my = icontext.invocationContext;
|
var my = icontext.invocationContext;
|
||||||
|
|
||||||
|
if (my.subscribed) {
|
||||||
|
console.log('already subscribed, not initializing subscriptions');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (my.options.track_rider) {
|
if (my.options.track_rider) {
|
||||||
// subscribe to rider locations
|
// subscribe to rider locations
|
||||||
console.log('subscribing to ' + my.options.channels.rider_location);
|
console.log('subscribing to ' + my.options.channels.rider_location);
|
||||||
|
|
@ -68,6 +75,7 @@ class MapEventHandler {
|
||||||
my.mqtt.subscribe(my.options.channels.jo_origin);
|
my.mqtt.subscribe(my.options.channels.jo_origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my.subscribed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
onMessage(msg) {
|
onMessage(msg) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue