Skip to content

Commit e738246

Browse files
Keith BannisterKeith Bannister
Keith Bannister
authored and
Keith Bannister
committed
SEt client ID to user ID to prevent clients from disconnecting one another
1 parent d72a039 commit e738246

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

dashboard.js

+10-3
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ let userLastPositions = {}; // dictionary of most recent posObj keyed by user na
2727

2828

2929
function dashboard_init() {
30-
31-
mqtt_init();
30+
3231
map_init();
3332

3433
temp_chart_init();
@@ -60,7 +59,7 @@ function mqtt_login() {
6059
let password = document.getElementById("password").value;
6160
// For more options, see here: https://www.eclipse.org/paho/files/jsdoc/Paho.MQTT.Client.html
6261
connectOptions = {
63-
timeout:3,
62+
timeout:30,
6463
userName:username,
6564
password:password,
6665
onSuccess:onConnect,
@@ -71,6 +70,14 @@ function mqtt_login() {
7170

7271
// setStatus("Connecting...");
7372
$('#debug_logs').append("MQTT Client connecting...");
73+
74+
const clientId = username;
75+
// Create a client instance
76+
mqtt_client = new Paho.MQTT.Client(loc.hostname, Number(loc.port), clientId);
77+
78+
// set callback handlers
79+
mqtt_client.onConnectionLost = onConnectionLost;
80+
mqtt_client.onMessageArrived = onMessageArrived;
7481
mqtt_client.connect(connectOptions);
7582
return false
7683

0 commit comments

Comments
 (0)