Skip to content
This repository has been archived by the owner. It is now read-only.
[deprecated] – A WebSocket server wrapping hafas-monitor-departures.
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.editorconfig
.gitignore
.travis.yml
example.js
index.js
license.md
package.json
readme.md
test.js

readme.md

hafas-monitor-departures-ws-server

A WebSocket server wrapping hafas-monitor-departures.

Deprecated. Use hafas-live-ws-server instead.

npm version build status ISC-licensed chat with me on Gitter support me on Patreon

Installing

npm install hafas-monitor-departures-ws-server

Usage

const createHafas = require('vbb-hafas')
const http = require('http')

const createMonitorServer = require('.')

const stations = [ // array of station ids
	'900000100003' // alexanderplatz
]
const interval = 5 * 1000 // every 5 seconds

const httpServer = http.createServer()
const hafas = createHafas('my-awesome-program')
createMonitorServer(httpServer, hafas, stations, interval)
httpServer.listen(3000)

Let a client receive the data:

const WebSocket = require('ws')

const client = new WebSocket('ws://localhost:3000/')
client.on('message', (msg) => {
	try {
		const departure = JSON.parse(msg)
		console.log(departure)
	} catch (err) {
		console.error(err)
	}
})

Contributing

If you have a question or have difficulties using hafas-monitor-departures-ws-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.

You can’t perform that action at this time.