Node-Red configuration
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

index.d.ts 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /// <reference types="node" />
  2. import { EventEmitter } from "events";
  3. export declare type SocketId = string;
  4. export declare type Room = string;
  5. export interface BroadcastFlags {
  6. volatile?: boolean;
  7. compress?: boolean;
  8. local?: boolean;
  9. broadcast?: boolean;
  10. binary?: boolean;
  11. timeout?: number;
  12. }
  13. export interface BroadcastOptions {
  14. rooms: Set<Room>;
  15. except?: Set<SocketId>;
  16. flags?: BroadcastFlags;
  17. }
  18. export declare class Adapter extends EventEmitter {
  19. readonly nsp: any;
  20. rooms: Map<Room, Set<SocketId>>;
  21. sids: Map<SocketId, Set<Room>>;
  22. private readonly encoder;
  23. /**
  24. * In-memory adapter constructor.
  25. *
  26. * @param {Namespace} nsp
  27. */
  28. constructor(nsp: any);
  29. /**
  30. * To be overridden
  31. */
  32. init(): Promise<void> | void;
  33. /**
  34. * To be overridden
  35. */
  36. close(): Promise<void> | void;
  37. /**
  38. * Returns the number of Socket.IO servers in the cluster
  39. *
  40. * @public
  41. */
  42. serverCount(): Promise<number>;
  43. /**
  44. * Adds a socket to a list of room.
  45. *
  46. * @param {SocketId} id the socket id
  47. * @param {Set<Room>} rooms a set of rooms
  48. * @public
  49. */
  50. addAll(id: SocketId, rooms: Set<Room>): Promise<void> | void;
  51. /**
  52. * Removes a socket from a room.
  53. *
  54. * @param {SocketId} id the socket id
  55. * @param {Room} room the room name
  56. */
  57. del(id: SocketId, room: Room): Promise<void> | void;
  58. private _del;
  59. /**
  60. * Removes a socket from all rooms it's joined.
  61. *
  62. * @param {SocketId} id the socket id
  63. */
  64. delAll(id: SocketId): void;
  65. /**
  66. * Broadcasts a packet.
  67. *
  68. * Options:
  69. * - `flags` {Object} flags for this packet
  70. * - `except` {Array} sids that should be excluded
  71. * - `rooms` {Array} list of rooms to broadcast to
  72. *
  73. * @param {Object} packet the packet object
  74. * @param {Object} opts the options
  75. * @public
  76. */
  77. broadcast(packet: any, opts: BroadcastOptions): void;
  78. /**
  79. * Broadcasts a packet and expects multiple acknowledgements.
  80. *
  81. * Options:
  82. * - `flags` {Object} flags for this packet
  83. * - `except` {Array} sids that should be excluded
  84. * - `rooms` {Array} list of rooms to broadcast to
  85. *
  86. * @param {Object} packet the packet object
  87. * @param {Object} opts the options
  88. * @param clientCountCallback - the number of clients that received the packet
  89. * @param ack - the callback that will be called for each client response
  90. *
  91. * @public
  92. */
  93. broadcastWithAck(packet: any, opts: BroadcastOptions, clientCountCallback: (clientCount: number) => void, ack: (...args: any[]) => void): void;
  94. /**
  95. * Gets a list of sockets by sid.
  96. *
  97. * @param {Set<Room>} rooms the explicit set of rooms to check.
  98. */
  99. sockets(rooms: Set<Room>): Promise<Set<SocketId>>;
  100. /**
  101. * Gets the list of rooms a given socket has joined.
  102. *
  103. * @param {SocketId} id the socket id
  104. */
  105. socketRooms(id: SocketId): Set<Room> | undefined;
  106. /**
  107. * Returns the matching socket instances
  108. *
  109. * @param opts - the filters to apply
  110. */
  111. fetchSockets(opts: BroadcastOptions): Promise<any[]>;
  112. /**
  113. * Makes the matching socket instances join the specified rooms
  114. *
  115. * @param opts - the filters to apply
  116. * @param rooms - the rooms to join
  117. */
  118. addSockets(opts: BroadcastOptions, rooms: Room[]): void;
  119. /**
  120. * Makes the matching socket instances leave the specified rooms
  121. *
  122. * @param opts - the filters to apply
  123. * @param rooms - the rooms to leave
  124. */
  125. delSockets(opts: BroadcastOptions, rooms: Room[]): void;
  126. /**
  127. * Makes the matching socket instances disconnect
  128. *
  129. * @param opts - the filters to apply
  130. * @param close - whether to close the underlying connection
  131. */
  132. disconnectSockets(opts: BroadcastOptions, close: boolean): void;
  133. private apply;
  134. private computeExceptSids;
  135. /**
  136. * Send a packet to the other Socket.IO servers in the cluster
  137. * @param packet - an array of arguments, which may include an acknowledgement callback at the end
  138. */
  139. serverSideEmit(packet: any[]): void;
  140. }