iosignal 9.12.0 → 9.14.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.
@@ -6,6 +6,8 @@ import { EventEmitter } from 'eventemitter3';
6
6
  import * as stream from 'stream';
7
7
  import { Transform } from 'stream';
8
8
  import EventEmitter$1 from 'events';
9
+ import * as perf_hooks from 'perf_hooks';
10
+ import http from 'http';
9
11
  export { default as MBP } from 'meta-buffer-pack';
10
12
 
11
13
  type STATE = {
@@ -643,6 +645,119 @@ declare class FileLogger {
643
645
  log(msg: any): void;
644
646
  }
645
647
 
648
+ /**
649
+ * The tags all hosts of one server have claimed. Patterns never overlap, so a tag matches at most one.
650
+ */
651
+ declare class HostTable {
652
+ exact: Map<any, any>;
653
+ prefixes: any[];
654
+ hosts: Map<any, any>;
655
+ get size(): number;
656
+ add(host: any, entries: any): void;
657
+ remove(host: any): void;
658
+ match(tag: any): any;
659
+ remoteClosed(remote: any, ownsCid: any): void;
660
+ }
661
+ /**
662
+ * Game logic (or any server-side logic) inside the server process. Created by server.host().
663
+ *
664
+ * Events:
665
+ * 'message' (from, tag, ...args) a client signal to one of the inbound tags. from is the
666
+ * server's view of the sender (never anything in the payload).
667
+ * 'leave' (from, reason) a participant's connection closed (it no longer has its CID)
668
+ * 'error' (error) a 'message' or 'leave' handler threw
669
+ * 'close' () the host was closed
670
+ */
671
+ declare class Host extends EventEmitter$1<[never]> {
672
+ static from(remote: any): any;
673
+ constructor(manager: any, name: any, options?: {});
674
+ name: string;
675
+ manager: any;
676
+ fanout: any;
677
+ retainTags: any;
678
+ retainBytes: any;
679
+ retainOwnerKey: string;
680
+ ownChannels: {
681
+ kind: string;
682
+ host: Host;
683
+ pattern: string;
684
+ text: string;
685
+ prefix: boolean;
686
+ unicast: boolean;
687
+ }[];
688
+ closed: boolean;
689
+ /** @type {Map<string, Readonly<object>>} cid -> from, connections that sent to this host */
690
+ _participants: Map<string, Readonly<object>>;
691
+ /** cid -> { inputs, firstAt, lastAt }: activity of each participant, for the dashboard */
692
+ _activity: Map<any, any>;
693
+ counters: {
694
+ inbound: number;
695
+ rejected: number;
696
+ denied: number;
697
+ published: number;
698
+ delivered: number;
699
+ sent: number;
700
+ joins: number;
701
+ leaves: number;
702
+ errors: number;
703
+ handlerMs: number;
704
+ };
705
+ handlerMaxMs: number;
706
+ reported: {};
707
+ _journal: any[];
708
+ _journalSeq: number;
709
+ _loops: Set<any>;
710
+ /** Connections that have sent to this host and are still online: cid -> from. */
711
+ get participants(): Map<string, object>;
712
+ /** Stop tracking a participant; no 'leave' is emitted for it (until it sends again). */
713
+ forget(cid: any): boolean;
714
+ /**
715
+ * Publish to one of the host's own channel tags. A tag with '$' is also retained, owned by the
716
+ * host. Returns the number of connections it was delivered to.
717
+ */
718
+ publish(tag: any, ...args: any[]): any;
719
+ /**
720
+ * Send to one connection. It receives '@' + topic. Returns false when the CID is not online
721
+ * or its receive buffer is too small for the message.
722
+ */
723
+ to(cid: any, topic: any, ...args: any[]): boolean;
724
+ /**
725
+ * Values to show on the server dashboard ("game" panel), e.g. { round: 3, players: 8 }.
726
+ * Merged into the last report; a key set to null is removed. Numbers, short strings and booleans,
727
+ * at most 20 keys.
728
+ */
729
+ report(values: any): this;
730
+ /**
731
+ * Run fn(now) every intervalMs, like setInterval, and measure it for the dashboard: the gap between
732
+ * ticks and how long each tick took. A throwing tick is reported as an 'error' and the loop goes on.
733
+ * Returns a stop function; close() stops every loop.
734
+ */
735
+ loop(intervalMs: any, fn: any): () => void;
736
+ /** Timing of the loops started with loop(): target, ticks, gap p50/p99 and step average/max (ms). */
737
+ loopStats(): {
738
+ intervalMs: any;
739
+ ticks: any;
740
+ gapP50: any;
741
+ gapP99: any;
742
+ gapMax: number;
743
+ stepAvg: number;
744
+ stepMax: number;
745
+ }[];
746
+ /** Participants with their activity: [{ from, inputs, firstAt, lastAt }]. */
747
+ activity(): any[];
748
+ /** Notable events after sequence `after`: [{ seq, at, kind: 'join'|'leave'|'denied'|'error', ... }]. */
749
+ journal(after?: number): any[];
750
+ _note(kind: any, data: any): void;
751
+ _denied(remote: any, tag: any): void;
752
+ _failed(error: any): void;
753
+ /** Release the tags (they become ordinary channels again) and the host's retained values. */
754
+ close(): void;
755
+ _open(): void;
756
+ _receive(remote: any, tag: any, message: any): boolean;
757
+ _remoteClosed(remote: any): void;
758
+ _emitSafely(name: any, ...args: any[]): void;
759
+ }
760
+
646
761
  declare class Metrics {
647
762
  constructor(manager: any);
648
763
  manager: any;
@@ -793,6 +908,9 @@ declare class Manager {
793
908
  rateLimited: number;
794
909
  peerRxLimitSkipped: number;
795
910
  policyDenied: number;
911
+ hostInbound: number;
912
+ hostRejected: number;
913
+ hostDenied: number;
796
914
  };
797
915
  authManager: any;
798
916
  connectionLogger: FileLogger | undefined;
@@ -806,6 +924,7 @@ declare class Manager {
806
924
  retainExpiry: Map<any, any>;
807
925
  retainBytes: number;
808
926
  channel_map: Map<any, any>;
927
+ hosts: HostTable;
809
928
  CHANNEL_PREFIX: string;
810
929
  CID_PREFIX: string;
811
930
  metrics: Metrics;
@@ -848,11 +967,13 @@ declare class Manager {
848
967
  adminSignal(cid: any, message: any): "no cid" | undefined;
849
968
  serverSignalTo(tag: any, ...args: any[]): "no cid" | undefined;
850
969
  sender(tag: any, remote: any, message: any): (string | number)[];
970
+ deliver(tag: any, message: any, fanout: any, publisher?: null): number | null;
971
+ hostPublish(host: any, tag: any, message: any): number;
851
972
  retainFits(message: any, freed: any, ownerBytes: any, budget: any): boolean;
852
973
  retainCopy(message: any): Buffer<ArrayBuffer>;
853
974
  storeCidRetain(key: any, message: any, remote: any): void;
854
975
  retainOwner(key: any): any;
855
- storeChannelRetain(tag: any, message: any, remote: any): void;
976
+ storeChannelRetain(tag: any, message: any, remote: any, host?: null): void;
856
977
  orphanChannelRetains(remote: any): void;
857
978
  expireChannelRetains(now?: number): void;
858
979
  dropChannelRetain(tag: any): void;
@@ -865,6 +986,135 @@ declare class Manager {
865
986
  close(): void;
866
987
  }
867
988
 
989
+ declare class ServerStats {
990
+ constructor(server: any, { onSample }?: {
991
+ onSample?: null | undefined;
992
+ });
993
+ server: any;
994
+ onSample: any;
995
+ base: any;
996
+ counters: {
997
+ opened: number;
998
+ closed: number;
999
+ authFailed: number;
1000
+ };
1001
+ onState: (_peer: any, _previous: any) => void;
1002
+ delay: perf_hooks.IntervalHistogram;
1003
+ cpu: NodeJS.CpuUsage;
1004
+ elu: perf_hooks.EventLoopUtilization;
1005
+ previousAt: number;
1006
+ previous: {
1007
+ opened: number;
1008
+ closed: number;
1009
+ authFailed: number;
1010
+ };
1011
+ timer: NodeJS.Timeout;
1012
+ sample(): void;
1013
+ value: {
1014
+ at: number;
1015
+ total: any;
1016
+ authenticated: number;
1017
+ anonymous: number;
1018
+ websocket: number;
1019
+ transports: {
1020
+ websocket: {
1021
+ total: number;
1022
+ authenticated: number;
1023
+ };
1024
+ tcp: {
1025
+ total: number;
1026
+ authenticated: number;
1027
+ };
1028
+ };
1029
+ hostAvailableBytes: number | null;
1030
+ hostTotalBytes: number;
1031
+ channels: any;
1032
+ states: {};
1033
+ queuedBytes: number;
1034
+ maxQueuedBytes: number;
1035
+ txQueuePeakBytes: number;
1036
+ txWriteFalseCount: number;
1037
+ txDrainMaxMs: number;
1038
+ txBlockedConnections: number;
1039
+ txBlockedMaxMs: number;
1040
+ counters: {
1041
+ opened: number;
1042
+ closed: number;
1043
+ authFailed: number;
1044
+ };
1045
+ rates: {
1046
+ [k: string]: number;
1047
+ };
1048
+ rss: number;
1049
+ heapUsed: number;
1050
+ cpuPercent: number;
1051
+ eventLoopUtilization: number;
1052
+ eventLoopP99Ms: number;
1053
+ quota: {
1054
+ anonymous: any;
1055
+ profiles: any;
1056
+ };
1057
+ } | undefined;
1058
+ dispose(): void;
1059
+ }
1060
+
1061
+ /**
1062
+ * The server dashboard: a web page (options.path) that shows the server and its hosts live.
1063
+ * It talks to the page through IOSignal itself: viewers send 'hello' to DASHBOARD.IN, a host checks
1064
+ * access, and every second it sends the latest sample to each viewer with host.to().
1065
+ *
1066
+ * options (all optional):
1067
+ * path: '/dashboard'
1068
+ * access: 'open' | { token: '...' } | { login: { roles: ['admin'], cids: [] } }
1069
+ * panels: panels shown first (DASHBOARD_PANELS); viewers can switch them
1070
+ * history: seconds kept for the charts (default 300, 10-3600)
1071
+ * maxViewers: default 20
1072
+ * showIdentities: show participant CIDs and names (default: true unless access is 'open')
1073
+ */
1074
+ declare class Dashboard {
1075
+ constructor(server: any, options?: {});
1076
+ path: string;
1077
+ access: {
1078
+ mode: string;
1079
+ hash?: undefined;
1080
+ roles?: undefined;
1081
+ cids?: undefined;
1082
+ } | {
1083
+ mode: string;
1084
+ hash: NonSharedBuffer;
1085
+ roles?: undefined;
1086
+ cids?: undefined;
1087
+ } | {
1088
+ mode: string;
1089
+ roles: any[];
1090
+ cids: Set<any>;
1091
+ hash?: undefined;
1092
+ };
1093
+ panels: any[];
1094
+ history: any;
1095
+ maxViewers: any;
1096
+ showIdentities: any;
1097
+ server: any;
1098
+ startedAt: number;
1099
+ viewers: Map<any, any>;
1100
+ series: any[];
1101
+ lastHostCounters: Map<any, any>;
1102
+ lastJournal: Map<any, any>;
1103
+ events: any[];
1104
+ host: any;
1105
+ stats: ServerStats;
1106
+ /** Whether this viewer (the server's view of it) may watch. */
1107
+ allowed(from: any, msg: any): boolean;
1108
+ /**
1109
+ * Serves the page (GET path) and the browser client (path + '/io.js'). Returns true when it
1110
+ * answered. A Server with `port` calls it itself; with your own httpServer call it first in
1111
+ * your request handler: if (server.dashboard.handle(req, res)) return
1112
+ */
1113
+ handle(req: any, res: any): boolean;
1114
+ close(): void;
1115
+ #private;
1116
+ }
1117
+
868
1118
  declare class Server extends EventEmitter$1<[never]> {
869
1119
  /**
870
1120
  * @param {object} options Server configuration.
@@ -891,6 +1141,9 @@ declare class Server extends EventEmitter$1<[never]> {
891
1141
  * options.anonymousQuota: profile of a connection that has not authenticated (default 'anonymous').
892
1142
  * options.duplicateLogin: 'keepOld' | 'keepNew' for this Server's connections; overrides the auth
893
1143
  * manager's own policy without changing it, so an auth manager can be shared between servers.
1144
+ * options.dashboard: true or { path, access, panels, history, maxViewers, showIdentities } shows a live
1145
+ * status page of the server and its hosts (see Dashboard.js); off by default. With `port` the Server
1146
+ * serves it itself; with your own httpServer call server.dashboard.handle(req, res) in its handler.
894
1147
  * A failed listen (e.g. EADDRINUSE) is emitted as 'error'.
895
1148
  * @param {any} [authManager] Optional authentication manager.
896
1149
  */
@@ -909,6 +1162,7 @@ declare class Server extends EventEmitter$1<[never]> {
909
1162
  membersOnly: boolean;
910
1163
  serviceNames: Set<any>;
911
1164
  services: Map<any, any>;
1165
+ hosts: Set<any>;
912
1166
  wss: any;
913
1167
  port: number | null;
914
1168
  congPort: number | null;
@@ -916,9 +1170,11 @@ declare class Server extends EventEmitter$1<[never]> {
916
1170
  httpServer: any;
917
1171
  wsPath: any;
918
1172
  manager: Manager;
1173
+ dashboard: Dashboard | null;
919
1174
  serverCountToListen: number;
920
1175
  listeningServerCount: number;
921
1176
  startWSServer(): void;
1177
+ ownHttp: http.Server<typeof http.IncomingMessage, typeof http.ServerResponse> | undefined;
922
1178
  startCongServer(): void;
923
1179
  congServer: any;
924
1180
  onListenerError(name: any, err: any): void;
@@ -960,6 +1216,27 @@ declare class Server extends EventEmitter$1<[never]> {
960
1216
  heapUsed: number;
961
1217
  };
962
1218
  };
1219
+ /**
1220
+ * Server-side logic (a game, a room) in this process. Signals clients send to the inbound tags go
1221
+ * to the host only, with the server's view of the sender; clients cannot send to the tags it owns.
1222
+ * @param {string} name 1-64 characters of A-Z a-z 0-9 _ . -
1223
+ * @param {{ inbound: string[], own?: string[], fanout?: number|null,
1224
+ * retain?: { tags?: number, bytes?: number } }} options
1225
+ * inbound: channel tags clients send to the host (a trailing '*' is a prefix). Not relayed.
1226
+ * own: channel tags only the host publishes, and '@topic' unicast topics only the host sends.
1227
+ * fanout: most subscribers one publish reaches (default null: all).
1228
+ * retain: budget of the host's retained ('$') values (default: retain.tagsPerOwner/bytesPerOwner).
1229
+ * @returns {Host}
1230
+ */
1231
+ host(name: string, options: {
1232
+ inbound: string[];
1233
+ own?: string[];
1234
+ fanout?: number | null;
1235
+ retain?: {
1236
+ tags?: number;
1237
+ bytes?: number;
1238
+ };
1239
+ }): Host;
963
1240
  /**
964
1241
  * RPC service register.
965
1242
  * service: service_name <string>
@@ -6,6 +6,8 @@ import { EventEmitter } from 'eventemitter3';
6
6
  import * as stream from 'stream';
7
7
  import { Transform } from 'stream';
8
8
  import EventEmitter$1 from 'events';
9
+ import * as perf_hooks from 'perf_hooks';
10
+ import http from 'http';
9
11
  export { default as MBP } from 'meta-buffer-pack';
10
12
 
11
13
  type STATE = {
@@ -643,6 +645,119 @@ declare class FileLogger {
643
645
  log(msg: any): void;
644
646
  }
645
647
 
648
+ /**
649
+ * The tags all hosts of one server have claimed. Patterns never overlap, so a tag matches at most one.
650
+ */
651
+ declare class HostTable {
652
+ exact: Map<any, any>;
653
+ prefixes: any[];
654
+ hosts: Map<any, any>;
655
+ get size(): number;
656
+ add(host: any, entries: any): void;
657
+ remove(host: any): void;
658
+ match(tag: any): any;
659
+ remoteClosed(remote: any, ownsCid: any): void;
660
+ }
661
+ /**
662
+ * Game logic (or any server-side logic) inside the server process. Created by server.host().
663
+ *
664
+ * Events:
665
+ * 'message' (from, tag, ...args) a client signal to one of the inbound tags. from is the
666
+ * server's view of the sender (never anything in the payload).
667
+ * 'leave' (from, reason) a participant's connection closed (it no longer has its CID)
668
+ * 'error' (error) a 'message' or 'leave' handler threw
669
+ * 'close' () the host was closed
670
+ */
671
+ declare class Host extends EventEmitter$1<[never]> {
672
+ static from(remote: any): any;
673
+ constructor(manager: any, name: any, options?: {});
674
+ name: string;
675
+ manager: any;
676
+ fanout: any;
677
+ retainTags: any;
678
+ retainBytes: any;
679
+ retainOwnerKey: string;
680
+ ownChannels: {
681
+ kind: string;
682
+ host: Host;
683
+ pattern: string;
684
+ text: string;
685
+ prefix: boolean;
686
+ unicast: boolean;
687
+ }[];
688
+ closed: boolean;
689
+ /** @type {Map<string, Readonly<object>>} cid -> from, connections that sent to this host */
690
+ _participants: Map<string, Readonly<object>>;
691
+ /** cid -> { inputs, firstAt, lastAt }: activity of each participant, for the dashboard */
692
+ _activity: Map<any, any>;
693
+ counters: {
694
+ inbound: number;
695
+ rejected: number;
696
+ denied: number;
697
+ published: number;
698
+ delivered: number;
699
+ sent: number;
700
+ joins: number;
701
+ leaves: number;
702
+ errors: number;
703
+ handlerMs: number;
704
+ };
705
+ handlerMaxMs: number;
706
+ reported: {};
707
+ _journal: any[];
708
+ _journalSeq: number;
709
+ _loops: Set<any>;
710
+ /** Connections that have sent to this host and are still online: cid -> from. */
711
+ get participants(): Map<string, object>;
712
+ /** Stop tracking a participant; no 'leave' is emitted for it (until it sends again). */
713
+ forget(cid: any): boolean;
714
+ /**
715
+ * Publish to one of the host's own channel tags. A tag with '$' is also retained, owned by the
716
+ * host. Returns the number of connections it was delivered to.
717
+ */
718
+ publish(tag: any, ...args: any[]): any;
719
+ /**
720
+ * Send to one connection. It receives '@' + topic. Returns false when the CID is not online
721
+ * or its receive buffer is too small for the message.
722
+ */
723
+ to(cid: any, topic: any, ...args: any[]): boolean;
724
+ /**
725
+ * Values to show on the server dashboard ("game" panel), e.g. { round: 3, players: 8 }.
726
+ * Merged into the last report; a key set to null is removed. Numbers, short strings and booleans,
727
+ * at most 20 keys.
728
+ */
729
+ report(values: any): this;
730
+ /**
731
+ * Run fn(now) every intervalMs, like setInterval, and measure it for the dashboard: the gap between
732
+ * ticks and how long each tick took. A throwing tick is reported as an 'error' and the loop goes on.
733
+ * Returns a stop function; close() stops every loop.
734
+ */
735
+ loop(intervalMs: any, fn: any): () => void;
736
+ /** Timing of the loops started with loop(): target, ticks, gap p50/p99 and step average/max (ms). */
737
+ loopStats(): {
738
+ intervalMs: any;
739
+ ticks: any;
740
+ gapP50: any;
741
+ gapP99: any;
742
+ gapMax: number;
743
+ stepAvg: number;
744
+ stepMax: number;
745
+ }[];
746
+ /** Participants with their activity: [{ from, inputs, firstAt, lastAt }]. */
747
+ activity(): any[];
748
+ /** Notable events after sequence `after`: [{ seq, at, kind: 'join'|'leave'|'denied'|'error', ... }]. */
749
+ journal(after?: number): any[];
750
+ _note(kind: any, data: any): void;
751
+ _denied(remote: any, tag: any): void;
752
+ _failed(error: any): void;
753
+ /** Release the tags (they become ordinary channels again) and the host's retained values. */
754
+ close(): void;
755
+ _open(): void;
756
+ _receive(remote: any, tag: any, message: any): boolean;
757
+ _remoteClosed(remote: any): void;
758
+ _emitSafely(name: any, ...args: any[]): void;
759
+ }
760
+
646
761
  declare class Metrics {
647
762
  constructor(manager: any);
648
763
  manager: any;
@@ -793,6 +908,9 @@ declare class Manager {
793
908
  rateLimited: number;
794
909
  peerRxLimitSkipped: number;
795
910
  policyDenied: number;
911
+ hostInbound: number;
912
+ hostRejected: number;
913
+ hostDenied: number;
796
914
  };
797
915
  authManager: any;
798
916
  connectionLogger: FileLogger | undefined;
@@ -806,6 +924,7 @@ declare class Manager {
806
924
  retainExpiry: Map<any, any>;
807
925
  retainBytes: number;
808
926
  channel_map: Map<any, any>;
927
+ hosts: HostTable;
809
928
  CHANNEL_PREFIX: string;
810
929
  CID_PREFIX: string;
811
930
  metrics: Metrics;
@@ -848,11 +967,13 @@ declare class Manager {
848
967
  adminSignal(cid: any, message: any): "no cid" | undefined;
849
968
  serverSignalTo(tag: any, ...args: any[]): "no cid" | undefined;
850
969
  sender(tag: any, remote: any, message: any): (string | number)[];
970
+ deliver(tag: any, message: any, fanout: any, publisher?: null): number | null;
971
+ hostPublish(host: any, tag: any, message: any): number;
851
972
  retainFits(message: any, freed: any, ownerBytes: any, budget: any): boolean;
852
973
  retainCopy(message: any): Buffer<ArrayBuffer>;
853
974
  storeCidRetain(key: any, message: any, remote: any): void;
854
975
  retainOwner(key: any): any;
855
- storeChannelRetain(tag: any, message: any, remote: any): void;
976
+ storeChannelRetain(tag: any, message: any, remote: any, host?: null): void;
856
977
  orphanChannelRetains(remote: any): void;
857
978
  expireChannelRetains(now?: number): void;
858
979
  dropChannelRetain(tag: any): void;
@@ -865,6 +986,135 @@ declare class Manager {
865
986
  close(): void;
866
987
  }
867
988
 
989
+ declare class ServerStats {
990
+ constructor(server: any, { onSample }?: {
991
+ onSample?: null | undefined;
992
+ });
993
+ server: any;
994
+ onSample: any;
995
+ base: any;
996
+ counters: {
997
+ opened: number;
998
+ closed: number;
999
+ authFailed: number;
1000
+ };
1001
+ onState: (_peer: any, _previous: any) => void;
1002
+ delay: perf_hooks.IntervalHistogram;
1003
+ cpu: NodeJS.CpuUsage;
1004
+ elu: perf_hooks.EventLoopUtilization;
1005
+ previousAt: number;
1006
+ previous: {
1007
+ opened: number;
1008
+ closed: number;
1009
+ authFailed: number;
1010
+ };
1011
+ timer: NodeJS.Timeout;
1012
+ sample(): void;
1013
+ value: {
1014
+ at: number;
1015
+ total: any;
1016
+ authenticated: number;
1017
+ anonymous: number;
1018
+ websocket: number;
1019
+ transports: {
1020
+ websocket: {
1021
+ total: number;
1022
+ authenticated: number;
1023
+ };
1024
+ tcp: {
1025
+ total: number;
1026
+ authenticated: number;
1027
+ };
1028
+ };
1029
+ hostAvailableBytes: number | null;
1030
+ hostTotalBytes: number;
1031
+ channels: any;
1032
+ states: {};
1033
+ queuedBytes: number;
1034
+ maxQueuedBytes: number;
1035
+ txQueuePeakBytes: number;
1036
+ txWriteFalseCount: number;
1037
+ txDrainMaxMs: number;
1038
+ txBlockedConnections: number;
1039
+ txBlockedMaxMs: number;
1040
+ counters: {
1041
+ opened: number;
1042
+ closed: number;
1043
+ authFailed: number;
1044
+ };
1045
+ rates: {
1046
+ [k: string]: number;
1047
+ };
1048
+ rss: number;
1049
+ heapUsed: number;
1050
+ cpuPercent: number;
1051
+ eventLoopUtilization: number;
1052
+ eventLoopP99Ms: number;
1053
+ quota: {
1054
+ anonymous: any;
1055
+ profiles: any;
1056
+ };
1057
+ } | undefined;
1058
+ dispose(): void;
1059
+ }
1060
+
1061
+ /**
1062
+ * The server dashboard: a web page (options.path) that shows the server and its hosts live.
1063
+ * It talks to the page through IOSignal itself: viewers send 'hello' to DASHBOARD.IN, a host checks
1064
+ * access, and every second it sends the latest sample to each viewer with host.to().
1065
+ *
1066
+ * options (all optional):
1067
+ * path: '/dashboard'
1068
+ * access: 'open' | { token: '...' } | { login: { roles: ['admin'], cids: [] } }
1069
+ * panels: panels shown first (DASHBOARD_PANELS); viewers can switch them
1070
+ * history: seconds kept for the charts (default 300, 10-3600)
1071
+ * maxViewers: default 20
1072
+ * showIdentities: show participant CIDs and names (default: true unless access is 'open')
1073
+ */
1074
+ declare class Dashboard {
1075
+ constructor(server: any, options?: {});
1076
+ path: string;
1077
+ access: {
1078
+ mode: string;
1079
+ hash?: undefined;
1080
+ roles?: undefined;
1081
+ cids?: undefined;
1082
+ } | {
1083
+ mode: string;
1084
+ hash: NonSharedBuffer;
1085
+ roles?: undefined;
1086
+ cids?: undefined;
1087
+ } | {
1088
+ mode: string;
1089
+ roles: any[];
1090
+ cids: Set<any>;
1091
+ hash?: undefined;
1092
+ };
1093
+ panels: any[];
1094
+ history: any;
1095
+ maxViewers: any;
1096
+ showIdentities: any;
1097
+ server: any;
1098
+ startedAt: number;
1099
+ viewers: Map<any, any>;
1100
+ series: any[];
1101
+ lastHostCounters: Map<any, any>;
1102
+ lastJournal: Map<any, any>;
1103
+ events: any[];
1104
+ host: any;
1105
+ stats: ServerStats;
1106
+ /** Whether this viewer (the server's view of it) may watch. */
1107
+ allowed(from: any, msg: any): boolean;
1108
+ /**
1109
+ * Serves the page (GET path) and the browser client (path + '/io.js'). Returns true when it
1110
+ * answered. A Server with `port` calls it itself; with your own httpServer call it first in
1111
+ * your request handler: if (server.dashboard.handle(req, res)) return
1112
+ */
1113
+ handle(req: any, res: any): boolean;
1114
+ close(): void;
1115
+ #private;
1116
+ }
1117
+
868
1118
  declare class Server extends EventEmitter$1<[never]> {
869
1119
  /**
870
1120
  * @param {object} options Server configuration.
@@ -891,6 +1141,9 @@ declare class Server extends EventEmitter$1<[never]> {
891
1141
  * options.anonymousQuota: profile of a connection that has not authenticated (default 'anonymous').
892
1142
  * options.duplicateLogin: 'keepOld' | 'keepNew' for this Server's connections; overrides the auth
893
1143
  * manager's own policy without changing it, so an auth manager can be shared between servers.
1144
+ * options.dashboard: true or { path, access, panels, history, maxViewers, showIdentities } shows a live
1145
+ * status page of the server and its hosts (see Dashboard.js); off by default. With `port` the Server
1146
+ * serves it itself; with your own httpServer call server.dashboard.handle(req, res) in its handler.
894
1147
  * A failed listen (e.g. EADDRINUSE) is emitted as 'error'.
895
1148
  * @param {any} [authManager] Optional authentication manager.
896
1149
  */
@@ -909,6 +1162,7 @@ declare class Server extends EventEmitter$1<[never]> {
909
1162
  membersOnly: boolean;
910
1163
  serviceNames: Set<any>;
911
1164
  services: Map<any, any>;
1165
+ hosts: Set<any>;
912
1166
  wss: any;
913
1167
  port: number | null;
914
1168
  congPort: number | null;
@@ -916,9 +1170,11 @@ declare class Server extends EventEmitter$1<[never]> {
916
1170
  httpServer: any;
917
1171
  wsPath: any;
918
1172
  manager: Manager;
1173
+ dashboard: Dashboard | null;
919
1174
  serverCountToListen: number;
920
1175
  listeningServerCount: number;
921
1176
  startWSServer(): void;
1177
+ ownHttp: http.Server<typeof http.IncomingMessage, typeof http.ServerResponse> | undefined;
922
1178
  startCongServer(): void;
923
1179
  congServer: any;
924
1180
  onListenerError(name: any, err: any): void;
@@ -960,6 +1216,27 @@ declare class Server extends EventEmitter$1<[never]> {
960
1216
  heapUsed: number;
961
1217
  };
962
1218
  };
1219
+ /**
1220
+ * Server-side logic (a game, a room) in this process. Signals clients send to the inbound tags go
1221
+ * to the host only, with the server's view of the sender; clients cannot send to the tags it owns.
1222
+ * @param {string} name 1-64 characters of A-Z a-z 0-9 _ . -
1223
+ * @param {{ inbound: string[], own?: string[], fanout?: number|null,
1224
+ * retain?: { tags?: number, bytes?: number } }} options
1225
+ * inbound: channel tags clients send to the host (a trailing '*' is a prefix). Not relayed.
1226
+ * own: channel tags only the host publishes, and '@topic' unicast topics only the host sends.
1227
+ * fanout: most subscribers one publish reaches (default null: all).
1228
+ * retain: budget of the host's retained ('$') values (default: retain.tagsPerOwner/bytesPerOwner).
1229
+ * @returns {Host}
1230
+ */
1231
+ host(name: string, options: {
1232
+ inbound: string[];
1233
+ own?: string[];
1234
+ fanout?: number | null;
1235
+ retain?: {
1236
+ tags?: number;
1237
+ bytes?: number;
1238
+ };
1239
+ }): Host;
963
1240
  /**
964
1241
  * RPC service register.
965
1242
  * service: service_name <string>