telemersive-bus 0.5.2 → 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.
package/lib/BusClient.js CHANGED
@@ -137,6 +137,9 @@ class BusClient {
137
137
  // if connection was successful, subscribe to roomAccess topic
138
138
  await this.communicator.subscribe(new BusMsgSub(this.busTopics.basePeerRoomAccess(this.peer.getClientId()).build(), this.onRoomJoined, RoomAccess, 0));
139
139
 
140
+ // now we start the timeout thread
141
+ this.joinTimeout = setTimeout(this.joinedTimeout,5000);
142
+
140
143
  // now we can send the room create message - knowing the manager
141
144
  // will resend the answer to a clientID protected topic
142
145
  await this.communicator.publish(
@@ -144,7 +147,6 @@ class BusClient {
144
147
  this.busTopics.roomCreate().build(),
145
148
  PeerCredentials, 1, false).encode(this.peer.getCredentials()));
146
149
 
147
- this.joinTimeout = setTimeout(this.joinedTimeout,5000);
148
150
  } else {
149
151
  this.bubbleUpCallback('bus', [ 'error', 'peer', 'cannot join unless connected']);
150
152
  }
@@ -161,7 +163,7 @@ class BusClient {
161
163
 
162
164
  joinedTimeout = () => {
163
165
  console.error(">>> room join timeout. manager not answering");
164
- //this.bubbleUpCallback('bus', [ 'peer', 'joined', 0]);
166
+ this.bubbleUpCallback('bus', [ 'peer', 'joined', 0]);
165
167
  this.bubbleUpCallback('bus', [ 'error', 'peer', 'timeout: manager is not answering']);
166
168
  }
167
169
 
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.2",
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": {