telemersive-bus 0.6.6 → 0.6.8

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
@@ -286,17 +286,20 @@ class BusManager {
286
286
  onPeerLeaving = async (_topic, _message, _packet) => {
287
287
  console.log(` <- peer '${_message.peerName}' leaving`);
288
288
  let shaPassword = sha1(_message.roomPwd).substr(0, 10)
289
- if (this.rooms[_message.roomName].roomPwd === shaPassword){
290
- // the actual message of this peer leaving the room is generated by the
291
- // housekeeping routine 'cleanOut':
292
- // we wait a moment to start with housekeeping, though.
293
- // it could be, that this message was called due to a short disconnect by the
294
- // peer to the broker - issuing a lastWill message by the broker.
295
- // by giving it some time the housekeeping process will verify if the peer
296
- // is still online or if it is really gone..
297
- setTimeout(this.startHousekeeping, houseKeepingTimeOut_onPeerLeft);
298
- } else {
299
- console.log(`!!! >BAD PLAYER<: somebody tried to remove peer without proper credentials!!!`);
289
+ if(this.rooms[_message.roomName] !== undefined){
290
+ // make sure the leaving peer leaves a still existing room
291
+ if (this.rooms[_message.roomName].roomPwd === shaPassword){
292
+ // the actual message of this peer leaving the room is generated by the
293
+ // housekeeping routine 'cleanOut':
294
+ // we wait a moment to start with housekeeping, though.
295
+ // it could be, that this message was called due to a short disconnect by the
296
+ // peer to the broker - issuing a lastWill message by the broker.
297
+ // by giving it some time the housekeeping process will verify if the peer
298
+ // is still online or if it is really gone..
299
+ setTimeout(this.startHousekeeping, houseKeepingTimeOut_onPeerLeft);
300
+ } else {
301
+ console.log(`!!! >BAD PLAYER<: somebody tried to remove peer without proper credentials!!!`);
302
+ }
300
303
  }
301
304
  };
302
305
 
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.6",
3
+ "version": "0.6.8",
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": {