@rljson/server 0.0.11 → 0.0.12

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/dist/server.d.ts CHANGED
@@ -93,6 +93,19 @@ export declare class Server extends BaseNode {
93
93
  * @returns The server instance.
94
94
  */
95
95
  addSocket(socket: SocketLike): Promise<this>;
96
+ /**
97
+ * Adds a socket to the multicast ring WITHOUT creating IoPeer/BsPeer.
98
+ * Use this when the hub needs to participate in the multicast (send and
99
+ * receive refs) but the server should NOT try to read data from this socket
100
+ * via IoPeer/BsPeer RPC — because no IoPeerBridge/BsPeerBridge is set up
101
+ * on the other end.
102
+ * Typical use case: hub creates a loopback socket pair so its own
103
+ * Connector can send/receive refs, but the server's IoMulti already has
104
+ * the hub's data in its local cache (IoMem/BsMem at priority 1).
105
+ * @param socket - Socket to register for broadcast only.
106
+ * @returns The server instance.
107
+ */
108
+ addBroadcastSocket(socket: SocketLike): Promise<this>;
96
109
  /**
97
110
  * Removes all listeners from all connected clients.
98
111
  */
package/dist/server.js CHANGED
@@ -799,6 +799,50 @@ class Server extends BaseNode {
799
799
  return this;
800
800
  }
801
801
  // ...........................................................................
802
+ /**
803
+ * Adds a socket to the multicast ring WITHOUT creating IoPeer/BsPeer.
804
+ * Use this when the hub needs to participate in the multicast (send and
805
+ * receive refs) but the server should NOT try to read data from this socket
806
+ * via IoPeer/BsPeer RPC — because no IoPeerBridge/BsPeerBridge is set up
807
+ * on the other end.
808
+ * Typical use case: hub creates a loopback socket pair so its own
809
+ * Connector can send/receive refs, but the server's IoMulti already has
810
+ * the hub's data in its local cache (IoMem/BsMem at priority 1).
811
+ * @param socket - Socket to register for broadcast only.
812
+ * @returns The server instance.
813
+ */
814
+ async addBroadcastSocket(socket) {
815
+ const sockets = normalizeSocketBundle(socket);
816
+ const clientId = `broadcast_${this._clients.size}_${Math.random().toString(36).slice(2)}`;
817
+ this._logger.info("Server", "Adding broadcast-only socket", { clientId });
818
+ const ioUp = sockets.ioUp;
819
+ const ioDown = sockets.ioDown;
820
+ const bsUp = sockets.bsUp;
821
+ const bsDown = sockets.bsDown;
822
+ ioUp.__clientId = clientId;
823
+ ioDown.__clientId = clientId;
824
+ bsUp.__clientId = clientId;
825
+ bsDown.__clientId = clientId;
826
+ this._clients.set(clientId, {
827
+ ioUp,
828
+ ioDown,
829
+ bsUp,
830
+ bsDown,
831
+ io: null,
832
+ bs: null
833
+ });
834
+ this._removeAllListeners();
835
+ this._multicastRefs();
836
+ this._registerDisconnectHandler(clientId, ioUp);
837
+ this._sendBootstrap(ioDown);
838
+ this._startBootstrapHeartbeat();
839
+ this._logger.info("Server", "Broadcast-only socket added", {
840
+ clientId,
841
+ totalClients: this._clients.size
842
+ });
843
+ return this;
844
+ }
845
+ // ...........................................................................
802
846
  /**
803
847
  * Removes all listeners from all connected clients.
804
848
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rljson/server",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "description": "Rljson server description",
5
5
  "homepage": "https://github.com/rljson/server",
6
6
  "bugs": "https://github.com/rljson/server/issues",