@stomp/stompjs 7.0.0-beta5 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +76 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,17 +16,82 @@ supports complete STOMP specifications including all current protocol variants.
|
|
|
16
16
|
popular messaging brokers support STOMP and STOMP over WebSockets out-of-the-box
|
|
17
17
|
or using plugins.
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
19
|
+
## Features
|
|
20
|
+
|
|
21
|
+
- Simple API to interact with the Stomp protocol
|
|
22
|
+
- Support for v1.2, v1.1 and v1.0 of the Stomp protocol
|
|
23
|
+
- Support for fallback options in case of WebSocket unavailable
|
|
24
|
+
- Browser and Node.js support
|
|
25
|
+
- Option to use STOMP over TCP
|
|
26
|
+
- Binary payload support
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
### Browser
|
|
31
|
+
|
|
32
|
+
```html
|
|
33
|
+
<!--
|
|
34
|
+
JSPM Generator Import Map
|
|
35
|
+
Edit URL: https://generator.jspm.io/#U2NgYGBkDM0rySzJSU1hcCguyc8t0AeTWcUO5noGega6SakliaYAYTzJAykA
|
|
36
|
+
-->
|
|
37
|
+
<script type="importmap">
|
|
38
|
+
{
|
|
39
|
+
"imports": {
|
|
40
|
+
"@stomp/stompjs": "https://ga.jspm.io/npm:@stomp/stompjs@7.0.0/esm6/index.js"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<!-- ES Module Shims: Import maps polyfill for modules browsers without import maps support (all except Chrome 89+) -->
|
|
46
|
+
<script
|
|
47
|
+
async
|
|
48
|
+
src="https://ga.jspm.io/npm:es-module-shims@1.5.1/dist/es-module-shims.js"
|
|
49
|
+
crossorigin="anonymous"
|
|
50
|
+
></script>
|
|
51
|
+
|
|
52
|
+
<script type="module">
|
|
53
|
+
import { Client } from '@stomp/stompjs';
|
|
54
|
+
|
|
55
|
+
const client = new Client({
|
|
56
|
+
brokerURL: 'ws://localhost:15674/ws',
|
|
57
|
+
onConnect: () => {
|
|
58
|
+
client.subscribe('/topic/test01', message =>
|
|
59
|
+
console.log(`Received: ${message.body}`)
|
|
60
|
+
);
|
|
61
|
+
client.publish({ destination: '/topic/test01', body: 'First Message' });
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
client.activate();
|
|
66
|
+
</script>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### NodeJS
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
$ npm install @stomp/stompjs ws
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
```javascript
|
|
76
|
+
import { Client } from '@stomp/stompjs';
|
|
77
|
+
|
|
78
|
+
import { WebSocket } from 'ws';
|
|
79
|
+
Object.assign(global, { WebSocket });
|
|
80
|
+
|
|
81
|
+
const client = new Client({
|
|
82
|
+
brokerURL: 'ws://localhost:15674/ws',
|
|
83
|
+
onConnect: () => {
|
|
84
|
+
client.subscribe('/topic/test01', message =>
|
|
85
|
+
console.log(`Received: ${message.body}`)
|
|
86
|
+
);
|
|
87
|
+
client.publish({ destination: '/topic/test01', body: 'First Message' });
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
client.activate();
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Further information
|
|
30
95
|
|
|
31
96
|
The API documentation is hosted as GitHub pages for the StompJS family of libraries.
|
|
32
97
|
You may head straight to the https://stomp-js.github.io/api-docs/latest/
|