source: trip-planner-front/node_modules/socket.io-adapter/dist/index.d.ts@ ceaed42

Last change on this file since ceaed42 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.2 KB
Line 
1/// <reference types="node" />
2import { EventEmitter } from "events";
3export declare type SocketId = string;
4export declare type Room = string;
5export interface BroadcastFlags {
6 volatile?: boolean;
7 compress?: boolean;
8 local?: boolean;
9 broadcast?: boolean;
10 binary?: boolean;
11}
12export interface BroadcastOptions {
13 rooms: Set<Room>;
14 except?: Set<SocketId>;
15 flags?: BroadcastFlags;
16}
17export declare class Adapter extends EventEmitter {
18 readonly nsp: any;
19 rooms: Map<Room, Set<SocketId>>;
20 sids: Map<SocketId, Set<Room>>;
21 private readonly encoder;
22 /**
23 * In-memory adapter constructor.
24 *
25 * @param {Namespace} nsp
26 */
27 constructor(nsp: any);
28 /**
29 * To be overridden
30 */
31 init(): Promise<void> | void;
32 /**
33 * To be overridden
34 */
35 close(): Promise<void> | void;
36 /**
37 * Adds a socket to a list of room.
38 *
39 * @param {SocketId} id the socket id
40 * @param {Set<Room>} rooms a set of rooms
41 * @public
42 */
43 addAll(id: SocketId, rooms: Set<Room>): Promise<void> | void;
44 /**
45 * Removes a socket from a room.
46 *
47 * @param {SocketId} id the socket id
48 * @param {Room} room the room name
49 */
50 del(id: SocketId, room: Room): Promise<void> | void;
51 private _del;
52 /**
53 * Removes a socket from all rooms it's joined.
54 *
55 * @param {SocketId} id the socket id
56 */
57 delAll(id: SocketId): void;
58 /**
59 * Broadcasts a packet.
60 *
61 * Options:
62 * - `flags` {Object} flags for this packet
63 * - `except` {Array} sids that should be excluded
64 * - `rooms` {Array} list of rooms to broadcast to
65 *
66 * @param {Object} packet the packet object
67 * @param {Object} opts the options
68 * @public
69 */
70 broadcast(packet: any, opts: BroadcastOptions): void;
71 /**
72 * Gets a list of sockets by sid.
73 *
74 * @param {Set<Room>} rooms the explicit set of rooms to check.
75 */
76 sockets(rooms: Set<Room>): Promise<Set<SocketId>>;
77 /**
78 * Gets the list of rooms a given socket has joined.
79 *
80 * @param {SocketId} id the socket id
81 */
82 socketRooms(id: SocketId): Set<Room> | undefined;
83}
Note: See TracBrowser for help on using the repository browser.