export = ClientSet; /** * @exports ClientSet * @class ClientSet * @extends Set * @author 7kasper * @classdesc * Special set implementation for clients. * Allows the same communication functions for clients but on an entire set. * * **Channel-aware publish.** When this set is owned by a {@link SubscriptionMap} * (the normal case), it carries its own `name` (the channel name). Every * broadcast method below mints one publishId per call and forwards it, * together with the channel name, to each member as the trailing arguments * to whatever client method is being invoked: * * `client.obj(payload, channel, publishId)` * `client.str(text, channel, publishId)` * `client.bin(buffer, channel, publishId)` * …etc. * * Plain {@link Client}s ignore the trailing args and behave as before * (JavaScript variadic forgiveness). {@link ProxyClient} overrides each * method to inspect the `(channel, publishId)` tuple and route through the * peer link's shadow buffer — multiple ProxyClients on the same peer + * same `(channel, publishId)` collapse to a single wire frame. * * Manual `forEach`/iteration loops bypass this — they call `c.obj(payload)` * directly with one arg, which on a ProxyClient is interpreted as a tagged * direct delivery (one wire frame per ProxyClient). That is intentional: * an explicit iteration loop is interpreted as the caller wanting per-client * semantics. */ declare class ClientSet extends Set { constructor(values?: readonly import("../client/Client")[]); constructor(iterable?: Iterable); /** * Ok every client. Channel-aware so a ProxyClient may translate this * to a coalesced shadow `ok` on its peer link, replayed on the * receiving side as `subs(channel).ok()`. */ ok(): void; /** * Sends an object to every member. * @param {*} obj - the payload to publish. */ obj(obj: any): void; /** * JSON-encodes every argument and sends a single string frame. */ json(...args: any[]): void; /** * Sends a plain string to every member. * @param {string} str */ str(str: string): void; /** * Sends a buffer (raw bytes) to every member. * @param {Buffer} buf */ buf(buf: Buffer): void; /** * Alias for {@link ClientSet#buf}, mirroring {@link Client#bin}. * @param {Buffer} buf */ bin(buf: Buffer): void; /** * Sends an error + statuscode to every member. * @param {*} err * @param {number} [code] */ err(err: any, code?: number): void; /** * Throws an client error in the neat way. */ throwErr(err: any): void; /** * Closes every member. For ProxyClients this fans out as a coalesced * shadow `close` so the receiving side closes every api client * subscribed to that channel — use sparingly; usually individual * `client.close()` is what you want. * @param {*} [reason] */ close(reason?: any): void; /** * Get or set a header property. HTTP-only; ignored by ws/proxy clients * — no coalescing applies. * @param {string} header * @param {string} [value] */ header(header: string, value?: string): void; /** * Get or set a cookie. HTTP-only; no coalescing. * @param {string} name * @param {any} [value] * @param {CookieOptions} [options] */ cookie(name: string, value?: any, options?: CookieOptions): void; /** * Compute the channel name + fresh publishId for one broadcast call. * When this ClientSet is not owned by a SubscriptionMap (i.e. there is * no channel name), `channel` is `undefined` and ProxyClients fall * back to per-client tagged delivery. * @private */ private _beginRound; } declare namespace ClientSet { export { nextPublishId, Client }; } declare function nextPublishId(): number; /** * Typedef Imports */ type Client = import("../client/Client");