versions.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /**
  2. * Supported STOMP versions
  3. *
  4. * Part of `@stomp/stompjs`.
  5. */
  6. export class Versions {
  7. /**
  8. * Takes an array of versions, typical elements '1.2', '1.1', or '1.0'
  9. *
  10. * You will be creating an instance of this class if you want to override
  11. * supported versions to be declared during STOMP handshake.
  12. */
  13. constructor(versions) {
  14. this.versions = versions;
  15. }
  16. /**
  17. * Used as part of CONNECT STOMP Frame
  18. */
  19. supportedVersions() {
  20. return this.versions.join(',');
  21. }
  22. /**
  23. * Used while creating a WebSocket
  24. */
  25. protocolVersions() {
  26. return this.versions.map(x => `v${x.replace('.', '')}.stomp`);
  27. }
  28. }
  29. /**
  30. * Indicates protocol version 1.0
  31. */
  32. Versions.V1_0 = '1.0';
  33. /**
  34. * Indicates protocol version 1.1
  35. */
  36. Versions.V1_1 = '1.1';
  37. /**
  38. * Indicates protocol version 1.2
  39. */
  40. Versions.V1_2 = '1.2';
  41. /**
  42. * @internal
  43. */
  44. Versions.default = new Versions([
  45. Versions.V1_2,
  46. Versions.V1_1,
  47. Versions.V1_0,
  48. ]);
  49. //# sourceMappingURL=versions.js.map