1
0
mirror of https://github.com/hotomoe/hotomoe synced 2024-12-26 04:28:07 +09:00
hotomoe/src/api/stream/server.ts

20 lines
414 B
TypeScript
Raw Normal View History

2017-06-09 01:03:54 +09: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 onStats = stats => {
connection.send(JSON.stringify({
type: 'stats',
body: stats
}));
};
ev.addListener('stats', onStats);
connection.on('close', () => {
ev.removeListener('stats', onStats);
});
}