iosignal 9.12.0 → 9.13.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.
- package/dist/browser/esm/io.js +5 -5
- package/dist/browser/esm/io.js.map +1 -1
- package/dist/browser/iife/io.js +5 -5
- package/dist/browser/iife/io.js.map +1 -1
- package/dist/node/iosignal.cjs +398 -118
- package/dist/node/iosignal.d.cts +94 -1
- package/dist/node/iosignal.d.ts +94 -1
- package/dist/node/iosignal.js +398 -118
- package/dist/types/common/payload.d.ts +9 -0
- package/package.json +1 -1
package/dist/node/iosignal.d.cts
CHANGED
|
@@ -643,6 +643,71 @@ declare class FileLogger {
|
|
|
643
643
|
log(msg: any): void;
|
|
644
644
|
}
|
|
645
645
|
|
|
646
|
+
/**
|
|
647
|
+
* The tags all hosts of one server have claimed. Patterns never overlap, so a tag matches at most one.
|
|
648
|
+
*/
|
|
649
|
+
declare class HostTable {
|
|
650
|
+
exact: Map<any, any>;
|
|
651
|
+
prefixes: any[];
|
|
652
|
+
hosts: Map<any, any>;
|
|
653
|
+
get size(): number;
|
|
654
|
+
add(host: any, entries: any): void;
|
|
655
|
+
remove(host: any): void;
|
|
656
|
+
match(tag: any): any;
|
|
657
|
+
remoteClosed(remote: any, ownsCid: any): void;
|
|
658
|
+
}
|
|
659
|
+
/**
|
|
660
|
+
* Game logic (or any server-side logic) inside the server process. Created by server.host().
|
|
661
|
+
*
|
|
662
|
+
* Events:
|
|
663
|
+
* 'message' (from, tag, ...args) a client signal to one of the inbound tags. from is the
|
|
664
|
+
* server's view of the sender (never anything in the payload).
|
|
665
|
+
* 'leave' (from, reason) a participant's connection closed (it no longer has its CID)
|
|
666
|
+
* 'error' (error) a 'message' or 'leave' handler threw
|
|
667
|
+
* 'close' () the host was closed
|
|
668
|
+
*/
|
|
669
|
+
declare class Host extends EventEmitter$1<[never]> {
|
|
670
|
+
static from(remote: any): any;
|
|
671
|
+
constructor(manager: any, name: any, options?: {});
|
|
672
|
+
name: string;
|
|
673
|
+
manager: any;
|
|
674
|
+
fanout: any;
|
|
675
|
+
retainTags: any;
|
|
676
|
+
retainBytes: any;
|
|
677
|
+
retainOwnerKey: string;
|
|
678
|
+
ownChannels: {
|
|
679
|
+
kind: string;
|
|
680
|
+
host: Host;
|
|
681
|
+
pattern: string;
|
|
682
|
+
text: string;
|
|
683
|
+
prefix: boolean;
|
|
684
|
+
unicast: boolean;
|
|
685
|
+
}[];
|
|
686
|
+
closed: boolean;
|
|
687
|
+
/** @type {Map<string, Readonly<object>>} cid -> from, connections that sent to this host */
|
|
688
|
+
_participants: Map<string, Readonly<object>>;
|
|
689
|
+
/** Connections that have sent to this host and are still online: cid -> from. */
|
|
690
|
+
get participants(): Map<string, object>;
|
|
691
|
+
/** Stop tracking a participant; no 'leave' is emitted for it (until it sends again). */
|
|
692
|
+
forget(cid: any): boolean;
|
|
693
|
+
/**
|
|
694
|
+
* Publish to one of the host's own channel tags. A tag with '$' is also retained, owned by the
|
|
695
|
+
* host. Returns the number of connections it was delivered to.
|
|
696
|
+
*/
|
|
697
|
+
publish(tag: any, ...args: any[]): any;
|
|
698
|
+
/**
|
|
699
|
+
* Send to one connection. It receives '@' + topic. Returns false when the CID is not online
|
|
700
|
+
* or its receive buffer is too small for the message.
|
|
701
|
+
*/
|
|
702
|
+
to(cid: any, topic: any, ...args: any[]): boolean;
|
|
703
|
+
/** Release the tags (they become ordinary channels again) and the host's retained values. */
|
|
704
|
+
close(): void;
|
|
705
|
+
_open(): void;
|
|
706
|
+
_receive(remote: any, tag: any, message: any): boolean;
|
|
707
|
+
_remoteClosed(remote: any): void;
|
|
708
|
+
_emitSafely(name: any, ...args: any[]): void;
|
|
709
|
+
}
|
|
710
|
+
|
|
646
711
|
declare class Metrics {
|
|
647
712
|
constructor(manager: any);
|
|
648
713
|
manager: any;
|
|
@@ -793,6 +858,9 @@ declare class Manager {
|
|
|
793
858
|
rateLimited: number;
|
|
794
859
|
peerRxLimitSkipped: number;
|
|
795
860
|
policyDenied: number;
|
|
861
|
+
hostInbound: number;
|
|
862
|
+
hostRejected: number;
|
|
863
|
+
hostDenied: number;
|
|
796
864
|
};
|
|
797
865
|
authManager: any;
|
|
798
866
|
connectionLogger: FileLogger | undefined;
|
|
@@ -806,6 +874,7 @@ declare class Manager {
|
|
|
806
874
|
retainExpiry: Map<any, any>;
|
|
807
875
|
retainBytes: number;
|
|
808
876
|
channel_map: Map<any, any>;
|
|
877
|
+
hosts: HostTable;
|
|
809
878
|
CHANNEL_PREFIX: string;
|
|
810
879
|
CID_PREFIX: string;
|
|
811
880
|
metrics: Metrics;
|
|
@@ -848,11 +917,13 @@ declare class Manager {
|
|
|
848
917
|
adminSignal(cid: any, message: any): "no cid" | undefined;
|
|
849
918
|
serverSignalTo(tag: any, ...args: any[]): "no cid" | undefined;
|
|
850
919
|
sender(tag: any, remote: any, message: any): (string | number)[];
|
|
920
|
+
deliver(tag: any, message: any, fanout: any, publisher?: null): number | null;
|
|
921
|
+
hostPublish(host: any, tag: any, message: any): number;
|
|
851
922
|
retainFits(message: any, freed: any, ownerBytes: any, budget: any): boolean;
|
|
852
923
|
retainCopy(message: any): Buffer<ArrayBuffer>;
|
|
853
924
|
storeCidRetain(key: any, message: any, remote: any): void;
|
|
854
925
|
retainOwner(key: any): any;
|
|
855
|
-
storeChannelRetain(tag: any, message: any, remote: any): void;
|
|
926
|
+
storeChannelRetain(tag: any, message: any, remote: any, host?: null): void;
|
|
856
927
|
orphanChannelRetains(remote: any): void;
|
|
857
928
|
expireChannelRetains(now?: number): void;
|
|
858
929
|
dropChannelRetain(tag: any): void;
|
|
@@ -909,6 +980,7 @@ declare class Server extends EventEmitter$1<[never]> {
|
|
|
909
980
|
membersOnly: boolean;
|
|
910
981
|
serviceNames: Set<any>;
|
|
911
982
|
services: Map<any, any>;
|
|
983
|
+
hosts: Set<any>;
|
|
912
984
|
wss: any;
|
|
913
985
|
port: number | null;
|
|
914
986
|
congPort: number | null;
|
|
@@ -960,6 +1032,27 @@ declare class Server extends EventEmitter$1<[never]> {
|
|
|
960
1032
|
heapUsed: number;
|
|
961
1033
|
};
|
|
962
1034
|
};
|
|
1035
|
+
/**
|
|
1036
|
+
* Server-side logic (a game, a room) in this process. Signals clients send to the inbound tags go
|
|
1037
|
+
* to the host only, with the server's view of the sender; clients cannot send to the tags it owns.
|
|
1038
|
+
* @param {string} name 1-64 characters of A-Z a-z 0-9 _ . -
|
|
1039
|
+
* @param {{ inbound: string[], own?: string[], fanout?: number|null,
|
|
1040
|
+
* retain?: { tags?: number, bytes?: number } }} options
|
|
1041
|
+
* inbound: channel tags clients send to the host (a trailing '*' is a prefix). Not relayed.
|
|
1042
|
+
* own: channel tags only the host publishes, and '@topic' unicast topics only the host sends.
|
|
1043
|
+
* fanout: most subscribers one publish reaches (default null: all).
|
|
1044
|
+
* retain: budget of the host's retained ('$') values (default: retain.tagsPerOwner/bytesPerOwner).
|
|
1045
|
+
* @returns {Host}
|
|
1046
|
+
*/
|
|
1047
|
+
host(name: string, options: {
|
|
1048
|
+
inbound: string[];
|
|
1049
|
+
own?: string[];
|
|
1050
|
+
fanout?: number | null;
|
|
1051
|
+
retain?: {
|
|
1052
|
+
tags?: number;
|
|
1053
|
+
bytes?: number;
|
|
1054
|
+
};
|
|
1055
|
+
}): Host;
|
|
963
1056
|
/**
|
|
964
1057
|
* RPC service register.
|
|
965
1058
|
* service: service_name <string>
|
package/dist/node/iosignal.d.ts
CHANGED
|
@@ -643,6 +643,71 @@ declare class FileLogger {
|
|
|
643
643
|
log(msg: any): void;
|
|
644
644
|
}
|
|
645
645
|
|
|
646
|
+
/**
|
|
647
|
+
* The tags all hosts of one server have claimed. Patterns never overlap, so a tag matches at most one.
|
|
648
|
+
*/
|
|
649
|
+
declare class HostTable {
|
|
650
|
+
exact: Map<any, any>;
|
|
651
|
+
prefixes: any[];
|
|
652
|
+
hosts: Map<any, any>;
|
|
653
|
+
get size(): number;
|
|
654
|
+
add(host: any, entries: any): void;
|
|
655
|
+
remove(host: any): void;
|
|
656
|
+
match(tag: any): any;
|
|
657
|
+
remoteClosed(remote: any, ownsCid: any): void;
|
|
658
|
+
}
|
|
659
|
+
/**
|
|
660
|
+
* Game logic (or any server-side logic) inside the server process. Created by server.host().
|
|
661
|
+
*
|
|
662
|
+
* Events:
|
|
663
|
+
* 'message' (from, tag, ...args) a client signal to one of the inbound tags. from is the
|
|
664
|
+
* server's view of the sender (never anything in the payload).
|
|
665
|
+
* 'leave' (from, reason) a participant's connection closed (it no longer has its CID)
|
|
666
|
+
* 'error' (error) a 'message' or 'leave' handler threw
|
|
667
|
+
* 'close' () the host was closed
|
|
668
|
+
*/
|
|
669
|
+
declare class Host extends EventEmitter$1<[never]> {
|
|
670
|
+
static from(remote: any): any;
|
|
671
|
+
constructor(manager: any, name: any, options?: {});
|
|
672
|
+
name: string;
|
|
673
|
+
manager: any;
|
|
674
|
+
fanout: any;
|
|
675
|
+
retainTags: any;
|
|
676
|
+
retainBytes: any;
|
|
677
|
+
retainOwnerKey: string;
|
|
678
|
+
ownChannels: {
|
|
679
|
+
kind: string;
|
|
680
|
+
host: Host;
|
|
681
|
+
pattern: string;
|
|
682
|
+
text: string;
|
|
683
|
+
prefix: boolean;
|
|
684
|
+
unicast: boolean;
|
|
685
|
+
}[];
|
|
686
|
+
closed: boolean;
|
|
687
|
+
/** @type {Map<string, Readonly<object>>} cid -> from, connections that sent to this host */
|
|
688
|
+
_participants: Map<string, Readonly<object>>;
|
|
689
|
+
/** Connections that have sent to this host and are still online: cid -> from. */
|
|
690
|
+
get participants(): Map<string, object>;
|
|
691
|
+
/** Stop tracking a participant; no 'leave' is emitted for it (until it sends again). */
|
|
692
|
+
forget(cid: any): boolean;
|
|
693
|
+
/**
|
|
694
|
+
* Publish to one of the host's own channel tags. A tag with '$' is also retained, owned by the
|
|
695
|
+
* host. Returns the number of connections it was delivered to.
|
|
696
|
+
*/
|
|
697
|
+
publish(tag: any, ...args: any[]): any;
|
|
698
|
+
/**
|
|
699
|
+
* Send to one connection. It receives '@' + topic. Returns false when the CID is not online
|
|
700
|
+
* or its receive buffer is too small for the message.
|
|
701
|
+
*/
|
|
702
|
+
to(cid: any, topic: any, ...args: any[]): boolean;
|
|
703
|
+
/** Release the tags (they become ordinary channels again) and the host's retained values. */
|
|
704
|
+
close(): void;
|
|
705
|
+
_open(): void;
|
|
706
|
+
_receive(remote: any, tag: any, message: any): boolean;
|
|
707
|
+
_remoteClosed(remote: any): void;
|
|
708
|
+
_emitSafely(name: any, ...args: any[]): void;
|
|
709
|
+
}
|
|
710
|
+
|
|
646
711
|
declare class Metrics {
|
|
647
712
|
constructor(manager: any);
|
|
648
713
|
manager: any;
|
|
@@ -793,6 +858,9 @@ declare class Manager {
|
|
|
793
858
|
rateLimited: number;
|
|
794
859
|
peerRxLimitSkipped: number;
|
|
795
860
|
policyDenied: number;
|
|
861
|
+
hostInbound: number;
|
|
862
|
+
hostRejected: number;
|
|
863
|
+
hostDenied: number;
|
|
796
864
|
};
|
|
797
865
|
authManager: any;
|
|
798
866
|
connectionLogger: FileLogger | undefined;
|
|
@@ -806,6 +874,7 @@ declare class Manager {
|
|
|
806
874
|
retainExpiry: Map<any, any>;
|
|
807
875
|
retainBytes: number;
|
|
808
876
|
channel_map: Map<any, any>;
|
|
877
|
+
hosts: HostTable;
|
|
809
878
|
CHANNEL_PREFIX: string;
|
|
810
879
|
CID_PREFIX: string;
|
|
811
880
|
metrics: Metrics;
|
|
@@ -848,11 +917,13 @@ declare class Manager {
|
|
|
848
917
|
adminSignal(cid: any, message: any): "no cid" | undefined;
|
|
849
918
|
serverSignalTo(tag: any, ...args: any[]): "no cid" | undefined;
|
|
850
919
|
sender(tag: any, remote: any, message: any): (string | number)[];
|
|
920
|
+
deliver(tag: any, message: any, fanout: any, publisher?: null): number | null;
|
|
921
|
+
hostPublish(host: any, tag: any, message: any): number;
|
|
851
922
|
retainFits(message: any, freed: any, ownerBytes: any, budget: any): boolean;
|
|
852
923
|
retainCopy(message: any): Buffer<ArrayBuffer>;
|
|
853
924
|
storeCidRetain(key: any, message: any, remote: any): void;
|
|
854
925
|
retainOwner(key: any): any;
|
|
855
|
-
storeChannelRetain(tag: any, message: any, remote: any): void;
|
|
926
|
+
storeChannelRetain(tag: any, message: any, remote: any, host?: null): void;
|
|
856
927
|
orphanChannelRetains(remote: any): void;
|
|
857
928
|
expireChannelRetains(now?: number): void;
|
|
858
929
|
dropChannelRetain(tag: any): void;
|
|
@@ -909,6 +980,7 @@ declare class Server extends EventEmitter$1<[never]> {
|
|
|
909
980
|
membersOnly: boolean;
|
|
910
981
|
serviceNames: Set<any>;
|
|
911
982
|
services: Map<any, any>;
|
|
983
|
+
hosts: Set<any>;
|
|
912
984
|
wss: any;
|
|
913
985
|
port: number | null;
|
|
914
986
|
congPort: number | null;
|
|
@@ -960,6 +1032,27 @@ declare class Server extends EventEmitter$1<[never]> {
|
|
|
960
1032
|
heapUsed: number;
|
|
961
1033
|
};
|
|
962
1034
|
};
|
|
1035
|
+
/**
|
|
1036
|
+
* Server-side logic (a game, a room) in this process. Signals clients send to the inbound tags go
|
|
1037
|
+
* to the host only, with the server's view of the sender; clients cannot send to the tags it owns.
|
|
1038
|
+
* @param {string} name 1-64 characters of A-Z a-z 0-9 _ . -
|
|
1039
|
+
* @param {{ inbound: string[], own?: string[], fanout?: number|null,
|
|
1040
|
+
* retain?: { tags?: number, bytes?: number } }} options
|
|
1041
|
+
* inbound: channel tags clients send to the host (a trailing '*' is a prefix). Not relayed.
|
|
1042
|
+
* own: channel tags only the host publishes, and '@topic' unicast topics only the host sends.
|
|
1043
|
+
* fanout: most subscribers one publish reaches (default null: all).
|
|
1044
|
+
* retain: budget of the host's retained ('$') values (default: retain.tagsPerOwner/bytesPerOwner).
|
|
1045
|
+
* @returns {Host}
|
|
1046
|
+
*/
|
|
1047
|
+
host(name: string, options: {
|
|
1048
|
+
inbound: string[];
|
|
1049
|
+
own?: string[];
|
|
1050
|
+
fanout?: number | null;
|
|
1051
|
+
retain?: {
|
|
1052
|
+
tags?: number;
|
|
1053
|
+
bytes?: number;
|
|
1054
|
+
};
|
|
1055
|
+
}): Host;
|
|
963
1056
|
/**
|
|
964
1057
|
* RPC service register.
|
|
965
1058
|
* service: service_name <string>
|