https://github.com/milesjos/ts-stomp
Simple TypeScript STOMP Library.
https://github.com/milesjos/ts-stomp
Last synced: 3 months ago
JSON representation
Simple TypeScript STOMP Library.
- Host: GitHub
- URL: https://github.com/milesjos/ts-stomp
- Owner: milesjos
- License: mit
- Created: 2018-06-18T15:34:11.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-06-18T17:13:21.000Z (almost 7 years ago)
- Last Synced: 2025-01-02T02:42:20.088Z (5 months ago)
- Language: TypeScript
- Size: 118 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: code-of-conduct.md
Awesome Lists containing this project
README
[](https://travis-ci.org/ElderByte-/ts-stomp)
[](https://www.npmjs.com/package/@elderbyte/ts-stomp)# TypeScript STOMP
Simple TypeScript STOMP over Websocket library.
## Features
* Supports native websocket transport
* Supports SockJS emulated websocket transportFor Angular 5 integration, have a look at [@elderbyte/ngx-stomp](https://github.com/ElderByte-/ngx-stomp)
## Consuming your library
To install this library, run:
```bash
$ 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:
```typescript
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 subscriptionsub.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:
```bash
$ npm run build
```To lint all `*.ts` files:
```bash
$ npm run lint
```## License
MIT © [ElderByte AG](mailto:[email protected])