telemersive-bus 0.6.10 → 0.6.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/BusClient.js CHANGED
@@ -132,7 +132,17 @@ class BusClient {
132
132
  // we reconnect with the final clientID. this protects this peer from a
133
133
  // potential BAD ACTOR spoofing as itself.
134
134
  this.communicator.setClientID(this.peer.getClientId());
135
- await this.communicator.reconnect(null);
135
+
136
+ console.log(` <-- reconnect to broker with correct last will...`);
137
+ // we reconnect again and set this time the correct last will message
138
+ // with the room info and password
139
+ // this should be done before we internally join the room and subscribe to all the
140
+ // topics
141
+ await this.communicator.reconnect(
142
+ new BusMsgPub(
143
+ this.busTopics.peerLeaving().build(),
144
+ PeerCredentials, 2, false).encode(this.peer.getCredentials()));
145
+ console.log(` <-- ... reconnected.`);
136
146
 
137
147
  // if connection was successful, subscribe to roomAccess topic
138
148
  await this.communicator.subscribe(new BusMsgSub(this.busTopics.basePeerRoomAccess(this.peer.getClientId()).build(), this.onRoomJoined, RoomAccess, 2));
@@ -140,6 +150,7 @@ class BusClient {
140
150
  // now we start the timeout thread
141
151
  this.joinTimeout = setTimeout(this.joinedTimeout,5000);
142
152
 
153
+ console.log(` <-- send request to create / join room...`);
143
154
  // now we can send the room create message - knowing the manager
144
155
  // will resend the answer to a clientID protected topic
145
156
  await this.communicator.publish(
@@ -192,17 +203,6 @@ class BusClient {
192
203
  if(!this.peer.isJoined()){
193
204
  console.log(`<-- access to room ${_message.roomName} accepted.`);
194
205
 
195
- console.log(` <-- reconnect to broker with correct last will...`);
196
- // we reconnect again and set this time the correct last will message
197
- // with the room info and password
198
- // this should be done before we internally join the room and subscribe to all the
199
- // topics
200
- await this.communicator.reconnect(
201
- new BusMsgPub(
202
- this.busTopics.peerLeaving().build(),
203
- PeerCredentials, 2, false).encode(this.peer.getCredentials()));
204
- console.log(` <-- ... reconnected.`);
205
-
206
206
  // now we can join the peer and give it its room id
207
207
  await this.peer.join(_message.roomId, _message.roomUuid);
208
208
 
package/lib/BusManager.js CHANGED
@@ -222,14 +222,28 @@ class BusManager {
222
222
  console.log(` -> peer '${_message.peerName}' not joined anymore - reject from room`);
223
223
  }
224
224
 
225
+ let room_ID = -1;
226
+ let room_UUID = -1;
227
+
228
+ // we also check if the room is still existing..
229
+ if (this.rooms[_message.roomName] !== undefined){
230
+ // we only set the id and UUID if the room still exists.
231
+ room_ID = this.rooms[_message.roomName].roomId;
232
+ room_UUID = this.rooms[_message.roomName].roomUUID;
233
+ } else {
234
+ accessGrant = false;
235
+ reason = "room doesn't exist anymore";
236
+ console.log(` -> peer '${_message.peerName}' reject from non existing room '${_message.roomName}'`);
237
+ }
238
+
225
239
  await this.publishRoomAccess(
226
240
  accessGrant,
227
241
  _message.peerId,
228
242
  _message.clientId,
229
243
  _message.peerName,
230
244
  _message.roomName,
231
- this.rooms[_message.roomName].roomId,
232
- this.rooms[_message.roomName].roomUUID,
245
+ room_ID,
246
+ room_UUID,
233
247
  _message.roomPwd,
234
248
  reason);
235
249
 
@@ -539,9 +553,6 @@ class BusManager {
539
553
  if (this.rooms.hasOwnProperty(_roomName)) {
540
554
  console.log(` <- remove room '${_roomName}' with id '${this.rooms[_roomName].roomId}' `);
541
555
  try {
542
- // stop the ports
543
- await this.stopServerSidePortScripts(_roomName, this.rooms[_roomName].roomId);
544
-
545
556
  // stop the and cleanup the room chat
546
557
  if (this.chatManagers.hasOwnProperty(_roomName)) {
547
558
  // stop the chatManager and delete it for this rom
@@ -567,7 +578,8 @@ class BusManager {
567
578
  // and by now all retained messages in this room have been cleaned up
568
579
  await this.communicator.unsubscribe(this.busTopics.baseRoomSubTopics(_roomName).build());
569
580
 
570
- delete this.rooms[_roomName];
581
+ // stop the ports and delete room for good
582
+ await this.stopServerSidePortScripts(_roomName, this.rooms[_roomName].roomId);
571
583
  } catch (e) {
572
584
  console.log(` <! exception while removing room '${_roomName}': '${e.message}' `);
573
585
  }
@@ -681,6 +693,8 @@ class BusManager {
681
693
  console.error(` ...: ${err}. Interrupting process of stopping open stage control instance on port ${_roomId * 1000 + 900}.`);
682
694
  }
683
695
  console.log(` <- stopped all ports for room ${_roomName}`);
696
+ delete this.rooms[_roomName];
697
+ console.log(` <- removed room ${_roomName}`);
684
698
  }else {
685
699
  console.log(` ...stopped no ports for room ${_roomName}: no switchboard url/port defined`);
686
700
  }
@@ -5,7 +5,7 @@ class Version {
5
5
  }
6
6
 
7
7
  getProtocolVersion = () => {
8
- return '0.0.5';
8
+ return '0.6.12';
9
9
  }
10
10
  }
11
11
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "telemersive-bus",
3
- "version": "0.6.10",
3
+ "version": "0.6.12",
4
4
  "description": "MQTT based data protocol to manage unlimited peers, connected by rooms, where all peers joined to a room can exchange private data. It provides a simple chat mechanism, latency pinging, publish-subscribe mechanism (based on mqtt) and a OSC-like data stream. ",
5
5
  "main": "index.js",
6
6
  "directories": {