telemersive-bus 0.6.7 → 0.6.9

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
@@ -62,7 +62,7 @@ class BusClient {
62
62
  connectServer = async () => {
63
63
  console.log("connect: attempting to connect to broker...")
64
64
  try{
65
- this.connectTimeout = setTimeout(this.connectionTimeout,1000);
65
+ this.connectTimeout = setTimeout(this.connectionTimeout,4000);
66
66
  await this.communicator.connect();
67
67
  // if connection was successful, subscribe to room info topic
68
68
  await this.communicator.subscribe(new BusMsgSub(this.busTopics.baseRoomInfo('+').build(), this.onRooms, RoomInfo, 2));
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 = 500;
15
+ const houseKeepingTimeOut = 1500;
16
16
  const houseKeepingTimeOut_onRepeat = 1500;
17
17
  const houseKeepingTimeOut_onPeerLeft= 1000;
18
18
  const houseKeepingTimeOut_onPeerJoined = 5000;
@@ -164,7 +164,7 @@ class BusManager {
164
164
 
165
165
  for (const key of keys) {
166
166
  // send ping message
167
- console.log(` -> room '${key}' with id '${this.rooms[key].roomId}'...`);
167
+ console.log(` -> room '${key}' with id '${this.rooms[key].roomId}' pings joined peers ...`);
168
168
  await this.communicator.publish(new BusMsgPub(this.busTopics.baseRoomAlive(key).build(), RoomInfo, 1, false).encode(
169
169
  {
170
170
  "timestamp": Math.round(new Date().getTime() / 1000),
@@ -240,7 +240,6 @@ class BusManager {
240
240
  */
241
241
  cleanOut = async () => {
242
242
  if(this.houseKeepingInProgress) {
243
- this.houseKeepingInProgress = false;
244
243
  console.log(` -> housekeeping -> cleaning out ...`);
245
244
  const cleanupAndLeave = async (currentPeer) => {
246
245
  console.log(` <- remove peer '${currentPeer.peerName}' from room '${currentPeer.roomName}' `);
@@ -278,6 +277,9 @@ class BusManager {
278
277
  await this.communicator.unsubscribe(this.busTopics.baseRoomAlivePing("+").build());
279
278
  // cleanup the communicator
280
279
  this.communicator.clearAutoGeneratedSubscriptions();
280
+ // set this flag to false at the end to make sure a new houskeeping cycle can only be started once
281
+ // all topics are unsubscribed - otherwise it won't gather the joined peers inside the room.
282
+ this.houseKeepingInProgress = false;
281
283
  }
282
284
 
283
285
  /**
@@ -547,7 +549,7 @@ class BusManager {
547
549
 
548
550
  delete this.rooms[_roomName];
549
551
  } catch (e) {
550
- console.log(" <! exception while removing room '${_roomName}': ${e.message}");
552
+ console.log(` <! exception while removing room '${_roomName}': '${e.message}' `);
551
553
  }
552
554
  }
553
555
  }
package/lib/utils/Peer.js CHANGED
@@ -192,14 +192,16 @@ class Peer {
192
192
  this.updateCallback();
193
193
 
194
194
  // it is important to start the subscription after a successfull joining.
195
+ // important to subscribe to my room ping messages first - otherwise we can run into the problem that we miss
196
+ // the room alive ping while building up the peer list.
197
+ await this.communicator.subscribe(new BusMsgSub(this.busTopics.baseRoomAlive(this.roomName).build(), this.onRoomPing, RoomInfo, 0));
198
+
195
199
  // subscribe to all peer joined messages
196
200
  await this.communicator.subscribe(new BusMsgSub(this.busTopics.roomPeerJoin(this.roomName, '+').build(), this.onPeerJoined, PeerInfo, 2));
197
201
 
198
202
  // subscribe to peer left messages
199
203
  await this.communicator.subscribe(new BusMsgSub(this.busTopics.roomPeerLeft(this.roomName, '+').build(), this.onPeerLeft, PeerInfo, 2));
200
204
 
201
- // subscribe to my room ping messages
202
- await this.communicator.subscribe(new BusMsgSub(this.busTopics.baseRoomAlive(this.roomName).build(), this.onRoomPing, RoomInfo, 0));
203
205
  console.log(" <-- ... local peer subscriptions complete");
204
206
  } else {
205
207
  if(decryptedRoomUuid !== this.roomUuid){
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "telemersive-bus",
3
- "version": "0.6.7",
3
+ "version": "0.6.9",
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": {