Sharkey/src/api/stream/requests.ts

20 lines
430 B
TypeScript
Raw Normal View History

2017-11-13 11:58:29 +01:00
import * as websocket from 'websocket';
import Xev from 'xev';
const ev = new Xev();
export default function homeStream(request: websocket.request, connection: websocket.connection): void {
const onRequest = request => {
connection.send(JSON.stringify({
type: 'request',
body: request
}));
};
ev.addListener('request', onRequest);
connection.on('close', () => {
ev.removeListener('request', onRequest);
});
}