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