File tree 1 file changed +5
-14
lines changed
1 file changed +5
-14
lines changed Original file line number Diff line number Diff line change @@ -29,25 +29,12 @@ let userLastPositions = {}; // dictionary of most recent posObj keyed by user na
29
29
function dashboard_init ( ) {
30
30
31
31
map_init ( ) ;
32
-
33
32
temp_chart_init ( ) ;
34
33
location_chart_init ( ) ;
35
34
36
-
37
- }
38
-
39
-
40
- function mqtt_init ( ) {
41
- // Create a client instance
42
- mqtt_client = new Paho . MQTT . Client ( loc . hostname , Number ( loc . port ) , "clientId" ) ;
43
-
44
- // set callback handlers
45
- mqtt_client . onConnectionLost = onConnectionLost ;
46
- mqtt_client . onMessageArrived = onMessageArrived ;
47
35
}
48
36
49
37
50
-
51
38
function setStatus ( msg ) {
52
39
// statusText.textContent = msg;
53
40
console . log ( "Status changed:" , msg ) ;
@@ -71,7 +58,11 @@ function mqtt_login() {
71
58
// setStatus("Connecting...");
72
59
$ ( '#debug_logs' ) . append ( "MQTT Client connecting..." ) ;
73
60
74
- const clientId = username ;
61
+ // Make a unique-ish, random client ID
62
+ const randint = Math . floor ( Math . random ( ) * 1024 * 1024 ) ;
63
+ // Client ID must be unique otherwise it disconnects the other client.
64
+ const clientId = `${ username } -${ randint } ` ;
65
+
75
66
// Create a client instance
76
67
mqtt_client = new Paho . MQTT . Client ( loc . hostname , Number ( loc . port ) , clientId ) ;
77
68
You can’t perform that action at this time.
0 commit comments