telemersive-bus 0.5.3 → 0.6.0

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 +50 -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
 
@@ -574,6 +577,17 @@ class BusManager {
574
577
  console.error(` ...: ${err}. Interrupting process of starting up one2manyBi script on port ${_roomId * 1000 + i * 10 + 0}.`);
575
578
  }
576
579
  }
580
+ // Stage Control Many to many proxy
581
+ try{
582
+ await this.addSwitchBoardProxy(_roomName,_roomId * 1000 + 902, _roomId * 1000 + 902, 'many2manyBi', "UDP proxy for Open Stage Control");
583
+ } catch(err){
584
+ console.error(` ...: ${err}. Interrupting process of starting up many2manyBi script on port ${_roomId * 1000 + 902}.`);
585
+ }
586
+ try{
587
+ await this.addSwitchBoardProxy(_roomName,_roomId * 1000 + 900, _roomId * 1000 + 902, 'OpenStageControl', "Open Stage Control instance");
588
+ } catch(err){
589
+ console.error(` ...: ${err}. Interrupting process of starting up many2manyBi script on port ${_roomId * 1000 + 902}.`);
590
+ }
577
591
  console.log(` <- started all ports for room ${_roomName}`);
578
592
  } else {
579
593
  console.log(` ...started no ports for room ${_roomName}: no switchboard url/port defined`);
@@ -608,6 +622,16 @@ class BusManager {
608
622
  console.error(` ...: ${err}. Interrupting process of stopping one2manyBi script on port ${_roomId * 1000 + i * 10 + 0}.`);
609
623
  }
610
624
  }
625
+ try{
626
+ await this.deleteSwitchBoardProxy(_roomId * 1000 + 902);
627
+ } catch(err){
628
+ console.error(` ...: ${err}. Interrupting process of stopping many2manyBi script on port ${_roomId * 1000 + 902}.`);
629
+ }
630
+ try{
631
+ await this.deleteSwitchBoardProxy(_roomId * 1000 + 900);
632
+ } catch(err){
633
+ console.error(` ...: ${err}. Interrupting process of stopping open stage control instance on port ${_roomId * 1000 + 900}.`);
634
+ }
611
635
  console.log(` <- stopped all ports for room ${_roomName}`);
612
636
  }else {
613
637
  console.log(` ...stopped no ports for room ${_roomName}: no switchboard url/port defined`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "telemersive-bus",
3
- "version": "0.5.3",
3
+ "version": "0.6.0",
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": {