Node-Red configuration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.d.ts 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /// <reference types="node" />
  2. /**
  3. * Current protocol version.
  4. */
  5. export declare const protocol = 3;
  6. /**
  7. * Packet types.
  8. */
  9. export declare const packets: {
  10. open: number;
  11. close: number;
  12. ping: number;
  13. pong: number;
  14. message: number;
  15. upgrade: number;
  16. noop: number;
  17. };
  18. /**
  19. * Encodes a packet.
  20. *
  21. * <packet type id> [ <data> ]
  22. *
  23. * Example:
  24. *
  25. * 5hello world
  26. * 3
  27. * 4
  28. *
  29. * Binary is encoded in an identical principle
  30. *
  31. * @api private
  32. */
  33. export declare function encodePacket(packet: any, supportsBinary: any, utf8encode: any, callback: any): any;
  34. /**
  35. * Encodes a packet with binary data in a base64 string
  36. *
  37. * @param {Object} packet, has `type` and `data`
  38. * @return {String} base64 encoded message
  39. */
  40. export declare function encodeBase64Packet(packet: any, callback: any): any;
  41. /**
  42. * Decodes a packet. Data also available as an ArrayBuffer if requested.
  43. *
  44. * @return {Object} with `type` and `data` (if any)
  45. * @api private
  46. */
  47. export declare function decodePacket(data: any, binaryType: any, utf8decode: any): {
  48. type: string;
  49. data: any;
  50. } | {
  51. type: string;
  52. data?: undefined;
  53. };
  54. /**
  55. * Decodes a packet encoded in a base64 string.
  56. *
  57. * @param {String} base64 encoded message
  58. * @return {Object} with `type` and `data` (if any)
  59. */
  60. export declare function decodeBase64Packet(msg: any, binaryType: any): {
  61. type: string;
  62. data: Buffer;
  63. };
  64. /**
  65. * Encodes multiple messages (payload).
  66. *
  67. * <length>:data
  68. *
  69. * Example:
  70. *
  71. * 11:hello world2:hi
  72. *
  73. * If any contents are binary, they will be encoded as base64 strings. Base64
  74. * encoded strings are marked with a b before the length specifier
  75. *
  76. * @param {Array} packets
  77. * @api private
  78. */
  79. export declare function encodePayload(packets: any, supportsBinary: any, callback: any): any;
  80. export declare function decodePayload(data: any, binaryType: any, callback: any): any;
  81. /**
  82. * Encodes multiple messages (payload) as binary.
  83. *
  84. * <1 = binary, 0 = string><number from 0-9><number from 0-9>[...]<number
  85. * 255><data>
  86. *
  87. * Example:
  88. * 1 3 255 1 2 3, if the binary contents are interpreted as 8 bit integers
  89. *
  90. * @param {Array} packets
  91. * @return {Buffer} encoded payload
  92. * @api private
  93. */
  94. export declare function encodePayloadAsBinary(packets: any, callback: any): any;
  95. export declare function decodePayloadAsBinary(data: any, binaryType: any, callback: any): any;