ws-stomp-server 1.0.0 → 1.0.1
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 +7 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -76,14 +76,14 @@ import express from 'express';
|
|
|
76
76
|
import { Stomp } from 'ws-stomp-server';
|
|
77
77
|
|
|
78
78
|
const app = express();
|
|
79
|
-
app.get('/send', (
|
|
79
|
+
app.get('/send', (_, res) => {
|
|
80
80
|
Stomp.publish('/topic/test', JSON.stringify({ name: 'hello word!' }));
|
|
81
|
-
res.status(200);
|
|
81
|
+
res.status(200).json({});
|
|
82
82
|
});
|
|
83
83
|
const server = app.listen(8080);
|
|
84
84
|
Stomp.server(server, '/ws');
|
|
85
|
-
Stomp.subscribe('/topic/test', (
|
|
86
|
-
|
|
85
|
+
Stomp.subscribe('/topic/test', (message) => {
|
|
86
|
+
console.log(message.body);
|
|
87
87
|
});
|
|
88
88
|
```
|
|
89
89
|
|
|
@@ -95,7 +95,9 @@ import { Client } from '@stomp/stompjs';
|
|
|
95
95
|
const client = new Client({
|
|
96
96
|
brokerURL: 'ws://localhost:8080/ws',
|
|
97
97
|
onConnect: () => {
|
|
98
|
-
client.subscribe('/topic/test', (message) =>
|
|
98
|
+
client.subscribe('/topic/test', (message) => {
|
|
99
|
+
console.log(message.body);
|
|
100
|
+
});
|
|
99
101
|
client.publish({ destination: '/topic/test', body: 'First Message' });
|
|
100
102
|
},
|
|
101
103
|
});
|