Node-Red configuration
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

socket.d.ts 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /// <reference types="node" />
  2. import { EventEmitter } from "events";
  3. import { IncomingMessage } from "http";
  4. import { Transport } from "./transport";
  5. import { RawData } from "engine.io-parser";
  6. export interface SendOptions {
  7. compress?: boolean;
  8. }
  9. declare type ReadyState = "opening" | "open" | "closing" | "closed";
  10. export declare class Socket extends EventEmitter {
  11. readonly protocol: number;
  12. request: IncomingMessage;
  13. readonly remoteAddress: string;
  14. _readyState: ReadyState;
  15. transport: Transport;
  16. private server;
  17. private upgrading;
  18. private upgraded;
  19. private writeBuffer;
  20. private packetsFn;
  21. private sentCallbackFn;
  22. private cleanupFn;
  23. private pingTimeoutTimer;
  24. private pingIntervalTimer;
  25. /**
  26. * This is the session identifier that the client will use in the subsequent HTTP requests. It must not be shared with
  27. * others parties, as it might lead to session hijacking.
  28. *
  29. * @private
  30. */
  31. private readonly id;
  32. get readyState(): ReadyState;
  33. set readyState(state: ReadyState);
  34. /**
  35. * Client class (abstract).
  36. *
  37. * @api private
  38. */
  39. constructor(id: any, server: any, transport: any, req: any, protocol: any);
  40. /**
  41. * Called upon transport considered open.
  42. *
  43. * @api private
  44. */
  45. private onOpen;
  46. /**
  47. * Called upon transport packet.
  48. *
  49. * @param {Object} packet
  50. * @api private
  51. */
  52. private onPacket;
  53. /**
  54. * Called upon transport error.
  55. *
  56. * @param {Error} err - error object
  57. * @api private
  58. */
  59. private onError;
  60. /**
  61. * Pings client every `this.pingInterval` and expects response
  62. * within `this.pingTimeout` or closes connection.
  63. *
  64. * @api private
  65. */
  66. private schedulePing;
  67. /**
  68. * Resets ping timeout.
  69. *
  70. * @api private
  71. */
  72. private resetPingTimeout;
  73. /**
  74. * Attaches handlers for the given transport.
  75. *
  76. * @param {Transport} transport
  77. * @api private
  78. */
  79. private setTransport;
  80. /**
  81. * Upgrades socket to the given transport
  82. *
  83. * @param {Transport} transport
  84. * @api private
  85. */
  86. private maybeUpgrade;
  87. /**
  88. * Clears listeners and timers associated with current transport.
  89. *
  90. * @api private
  91. */
  92. private clearTransport;
  93. /**
  94. * Called upon transport considered closed.
  95. * Possible reasons: `ping timeout`, `client error`, `parse error`,
  96. * `transport error`, `server close`, `transport close`
  97. */
  98. private onClose;
  99. /**
  100. * Setup and manage send callback
  101. *
  102. * @api private
  103. */
  104. private setupSendCallback;
  105. /**
  106. * Sends a message packet.
  107. *
  108. * @param {Object} data
  109. * @param {Object} options
  110. * @param {Function} callback
  111. * @return {Socket} for chaining
  112. * @api public
  113. */
  114. send(data: RawData, options?: SendOptions, callback?: () => void): this;
  115. /**
  116. * Alias of {@link send}.
  117. *
  118. * @param data
  119. * @param options
  120. * @param callback
  121. */
  122. write(data: RawData, options?: SendOptions, callback?: () => void): this;
  123. /**
  124. * Sends a packet.
  125. *
  126. * @param {String} type - packet type
  127. * @param {String} data
  128. * @param {Object} options
  129. * @param {Function} callback
  130. *
  131. * @api private
  132. */
  133. private sendPacket;
  134. /**
  135. * Attempts to flush the packets buffer.
  136. *
  137. * @api private
  138. */
  139. private flush;
  140. /**
  141. * Get available upgrades for this socket.
  142. *
  143. * @api private
  144. */
  145. private getAvailableUpgrades;
  146. /**
  147. * Closes the socket and underlying transport.
  148. *
  149. * @param {Boolean} discard - optional, discard the transport
  150. * @return {Socket} for chaining
  151. * @api public
  152. */
  153. close(discard?: boolean): void;
  154. /**
  155. * Closes the underlying transport.
  156. *
  157. * @param {Boolean} discard
  158. * @api private
  159. */
  160. private closeTransport;
  161. }
  162. export {};