mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-09 04:23:08 +02:00
20 lines
414 B
TypeScript
20 lines
414 B
TypeScript
|
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);
|
||
|
});
|
||
|
}
|