4.0.0 • Published 5 years ago
@elderbyte/ts-stomp v4.0.0
TypeScript STOMP
Simple TypeScript STOMP over Websocket library.
Features
- Supports native websocket transport
- Supports SockJS emulated websocket transport
For Angular integration, have a look at @elderbyte/ngx-stomp
Consuming your library
To install this library, run:
$ npm install @elderbyte/ts-stomp --save
and then in your code:
Once your library is imported, you can use the StompService
by importing it into your own services / components:
export class MyStompUsage {
private logger = LoggerFactory.getLogger('MyStompUsage');
private stompService : StompService
constructor(
) {
this.stompService = new StompService({
endpointUrl: '/stomp',
withSockJs: true
});
const topic = '/topic/metadata/changed';
// Subscribe to the STOMP topic ...
this.stompService.connectedClient
.subscribe(client => {
const sub = client.subscribe(topic);
// Subscription successful -> now we can listen to messages sent to this subscription
sub.messages.subscribe(m => {
// We got a message m, do something with it
this.onMediaChanged(m.bodyJson);
}, err => {
this.logger.error('Got filtered STOMP topic error!', err);
})
}, err => {
this.logger.error('STOMP: Failed to subscribe!', err);
});
}
}
Development
To generate all *.js
, *.d.ts
and *.metadata.json
files:
$ npm run build
To lint all *.ts
files:
$ npm run lint
License
MIT © ElderByte AG
4.0.0
5 years ago
3.0.0-beta4
6 years ago
2.1.2
6 years ago
3.0.0-beta3
6 years ago
3.0.0-beta2
6 years ago
3.0.0-beta
6 years ago
2.1.1
6 years ago
2.1.0
6 years ago
2.0.1
6 years ago
2.0.0
6 years ago
1.0.2
6 years ago
1.0.1
6 years ago
1.0.0
6 years ago