@rljson/server 0.0.11 → 0.0.13
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 +13 -0
- package/dist/server.js +44 -0
- package/package.json +2 -2
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.
|
|
3
|
+
"version": "0.0.13",
|
|
4
4
|
"description": "Rljson server description",
|
|
5
5
|
"homepage": "https://github.com/rljson/server",
|
|
6
6
|
"bugs": "https://github.com/rljson/server/issues",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@rljson/hash": "^0.0.18",
|
|
49
49
|
"@rljson/io": "^0.0.66",
|
|
50
50
|
"@rljson/json": "^0.0.23",
|
|
51
|
-
"@rljson/network": "^0.0.
|
|
51
|
+
"@rljson/network": "^0.0.9",
|
|
52
52
|
"@rljson/rljson": "^0.0.78"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|