telemersive-bus 0.5.3 → 0.5.4

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.
Files changed (2) hide show
  1. package/lib/BusManager.js +29 -26
  2. package/package.json +1 -1
package/lib/BusManager.js CHANGED
@@ -12,7 +12,7 @@ const {RoomAccess, RoomInfo, PeerCredentials, PeerInfo} = require('./protos/BusM
12
12
 
13
13
  /* time the housekeeping thread waits until it continues with the next step
14
14
  */
15
- const houseKeepingTimeOut = 100;
15
+ const houseKeepingTimeOut = 500;
16
16
  const ROOM_ID_MIN = 11;
17
17
  const ROOM_ID_MAX = 50;
18
18
 
@@ -490,36 +490,39 @@ class BusManager {
490
490
  // make sure the room really exists.
491
491
  if (this.rooms.hasOwnProperty(_roomName)) {
492
492
  console.log(` <- remove room '${_roomName}' with id '${this.rooms[_roomName].roomId}' `);
493
+ try {
494
+ // stop the ports
495
+ await this.stopServerSidePortScripts(_roomName, this.rooms[_roomName].roomId);
496
+
497
+ // stop the and cleanup the room chat
498
+ if (this.chatManagers.hasOwnProperty(_roomName)) {
499
+ // stop the chatManager and delete it for this rom
500
+ await this.chatManagers[_roomName].disconnect();
501
+ delete this.chatManagers[_roomName];
502
+ }
493
503
 
494
- // stop the ports
495
- await this.stopServerSidePortScripts(_roomName, this.rooms[_roomName].roomId);
496
-
497
- // stop the and cleanup the room chat
498
- if (this.chatManagers.hasOwnProperty(_roomName)) {
499
- // stop the chatManager and delete it for this rom
500
- await this.chatManagers[_roomName].disconnect();
501
- delete this.chatManagers[_roomName];
502
- }
503
-
504
- // then we subscribe to all retained messages of this room
505
- await this.communicator.subscribe(new BusMsgSub(this.busTopics.baseRoomSubTopics(_roomName).build(), this.onAllRoomTopics, null, 0));
504
+ // then we subscribe to all retained messages of this room
505
+ await this.communicator.subscribe(new BusMsgSub(this.busTopics.baseRoomSubTopics(_roomName).build(), this.onAllRoomTopics, null, 0));
506
506
 
507
- // send delete room message to all listening peers
508
- await this.communicator.publish(new BusMsgPub(this.busTopics.roomDelete(_roomName).build(), RoomInfo, 2, false).encode(
509
- {
510
- timestamp: Math.round(new Date().getTime() / 1000),
511
- roomId: this.rooms[_roomName].roomId,
512
- roomName: _roomName
513
- }
514
- ));
507
+ // send delete room message to all listening peers
508
+ await this.communicator.publish(new BusMsgPub(this.busTopics.roomDelete(_roomName).build(), RoomInfo, 2, false).encode(
509
+ {
510
+ timestamp: Math.round(new Date().getTime() / 1000),
511
+ roomId: this.rooms[_roomName].roomId,
512
+ roomName: _roomName
513
+ }
514
+ ));
515
515
 
516
- // clear retained info message
517
- await this.communicator.clearRetain(this.busTopics.baseRoomInfo(_roomName).build());
516
+ // clear retained info message
517
+ await this.communicator.clearRetain(this.busTopics.baseRoomInfo(_roomName).build());
518
518
 
519
- // and by now all retained messages in this room have been cleaned up
520
- await this.communicator.unsubscribe(this.busTopics.baseRoomSubTopics(_roomName).build());
519
+ // and by now all retained messages in this room have been cleaned up
520
+ await this.communicator.unsubscribe(this.busTopics.baseRoomSubTopics(_roomName).build());
521
521
 
522
- delete this.rooms[_roomName];
522
+ delete this.rooms[_roomName];
523
+ } catch (e) {
524
+ console.log(" <! exception while removing room '${_roomName}': ${e.message}");
525
+ }
523
526
  }
524
527
  }
525
528
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "telemersive-bus",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
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": {