frame-impl.d.ts 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. import { IFrame } from './i-frame.js';
  2. import { StompHeaders } from './stomp-headers.js';
  3. import { IRawFrameType } from './types.js';
  4. /**
  5. * Frame class represents a STOMP frame.
  6. *
  7. * @internal
  8. */
  9. export declare class FrameImpl implements IFrame {
  10. /**
  11. * STOMP Command
  12. */
  13. command: string;
  14. /**
  15. * Headers, key value pairs.
  16. */
  17. headers: StompHeaders;
  18. /**
  19. * Is this frame binary (based on whether body/binaryBody was passed when creating this frame).
  20. */
  21. isBinaryBody: boolean;
  22. /**
  23. * body of the frame
  24. */
  25. get body(): string;
  26. private _body;
  27. /**
  28. * body as Uint8Array
  29. */
  30. get binaryBody(): Uint8Array;
  31. private _binaryBody;
  32. private escapeHeaderValues;
  33. private skipContentLengthHeader;
  34. /**
  35. * Frame constructor. `command`, `headers` and `body` are available as properties.
  36. *
  37. * @internal
  38. */
  39. constructor(params: {
  40. command: string;
  41. headers?: StompHeaders;
  42. body?: string;
  43. binaryBody?: Uint8Array;
  44. escapeHeaderValues?: boolean;
  45. skipContentLengthHeader?: boolean;
  46. });
  47. /**
  48. * deserialize a STOMP Frame from raw data.
  49. *
  50. * @internal
  51. */
  52. static fromRawFrame(rawFrame: IRawFrameType, escapeHeaderValues: boolean): FrameImpl;
  53. /**
  54. * @internal
  55. */
  56. toString(): string;
  57. /**
  58. * serialize this Frame in a format suitable to be passed to WebSocket.
  59. * If the body is string the output will be string.
  60. * If the body is binary (i.e. of type Unit8Array) it will be serialized to ArrayBuffer.
  61. *
  62. * @internal
  63. */
  64. serialize(): string | ArrayBuffer;
  65. private serializeCmdAndHeaders;
  66. private isBodyEmpty;
  67. private bodyLength;
  68. /**
  69. * Compute the size of a UTF-8 string by counting its number of bytes
  70. * (and not the number of characters composing the string)
  71. */
  72. private static sizeOfUTF8;
  73. private static toUnit8Array;
  74. /**
  75. * Serialize a STOMP frame as per STOMP standards, suitable to be sent to the STOMP broker.
  76. *
  77. * @internal
  78. */
  79. static marshall(params: {
  80. command: string;
  81. headers?: StompHeaders;
  82. body?: string;
  83. binaryBody?: Uint8Array;
  84. escapeHeaderValues?: boolean;
  85. skipContentLengthHeader?: boolean;
  86. }): string | ArrayBuffer;
  87. /**
  88. * Escape header values
  89. */
  90. private static hdrValueEscape;
  91. /**
  92. * UnEscape header values
  93. */
  94. private static hdrValueUnEscape;
  95. }