import { Message } from '../Message.js'; import { SocketTransport } from '../transport.js'; import { SessionConnection } from './SessionConnection.js'; /** * The server side of the session layer: hand it each incoming socket and it * resolves which client it belongs to, new or returning. * * **It does not listen on anything.** This was `WebSocketServer` — a name that * collided with `ws`'s own class, which it built internally from an * `http.Server`. The caller now owns the listening socket, so this package needs * no WebSocket implementation at all; see `SocketTransport`. * * const server = new SessionServer(); * server.onConnection(client => client.onMessageType('ping', …)); * * // Node, with `ws`: * wss.on('connection', ws => server.accept(fromEventEmitter(ws))); * * `accept` does not emit a connection straight away: it waits for the client's * handshake, because that is what says whether this is a new client or one * coming back with a `ClientId`. A returning client is bound to its existing * `SessionConnection` and does **not** re-emit `onConnection`. */ export declare class SessionServer, ClientMessage extends Message> { private readonly clients; private readonly emitConnection; readonly onConnection: (listener: (data: SessionConnection) => void) => () => boolean; accept(transport: SocketTransport): void; private onClientConnected; /** * An id we do not know is not adopted — the client gets a fresh session, and * `onConnection` fires as it would for any newcomer. * * This used to be `get(id) || add(id)`, which took the id from the wire at face * value. Combined with sequential ids it meant naming another client's id was * enough to be handed their session; on its own it still let a client choose an * id nobody issued. */ private onClientReconnect; } //# sourceMappingURL=SessionServer.d.ts.map