https://github.com/derhuerst/hafas-monitor-trips-server
A server that manages HAFAS monitors.
https://github.com/derhuerst/hafas-monitor-trips-server
hafas polling public-transport transit
Last synced: 8 months ago
JSON representation
A server that manages HAFAS monitors.
- Host: GitHub
- URL: https://github.com/derhuerst/hafas-monitor-trips-server
- Owner: derhuerst
- License: isc
- Created: 2019-06-03T18:27:42.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-06-09T15:44:23.000Z (over 6 years ago)
- Last Synced: 2025-01-07T19:11:34.348Z (10 months ago)
- Topics: hafas, polling, public-transport, transit
- Language: JavaScript
- Homepage: https://github.com/derhuerst/hafas-monitor-trips-server#hafas-monitor-trips-server
- Size: 9.77 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license.md
Awesome Lists containing this project
README
# hafas-monitor-trips-server
**A server that manages [HAFAS monitors](https://github.com/derhuerst/hafas-monitor-trips).**
[](https://www.npmjs.com/package/hafas-monitor-trips-server)
[](https://travis-ci.org/derhuerst/hafas-monitor-trips-server)

[](https://gitter.im/derhuerst)
[](https://patreon.com/derhuerst)## Installation
```shell
npm install hafas-monitor-trips-server
```## Usage
```js
const createServer = require('hafas-monitor-trips-server')const server = createServer(hafas)
const subA = server.subscribe({
north: 52.51, south: 52.4, west: 13.35, east: 13.38
})
const subB = server.subscribe({
north: 52.505, south: 52.45, west: 13.355, east: 13.375
})subA.on('stopover', stopover => console.log('A', stopover))
subB.on('stopover', stopover => console.log('B', stopover))
```- `subA` and `subB` have overlapping bounding boxes, so they will share one monitor.
- `hafas` is a [`hafas-client`/`*-hafas`](https://npmjs.com/package/hafas-client) instance.
- `subscribe(bbox)` returns an [`EventEmitter`](https://nodejs.org/docs/latest-v12.x/api/events.html#events_class_eventemitter), emitting the same events as a [`hafas-monitor-trips`](https://npmjs.com/package/hafas-monitor-trips) instance.See [`example.js`](example.js) for a full example.
## Contributing
If you have a question or need support using `hafas-monitor-trips-server`, please double-check your code and setup first. If you think you have found a bug or want to propose a feature, refer to [the issues page](https://github.com/derhuerst/hafas-monitor-trips-server/issues).