nanka iroiro
This commit is contained in:
parent
f93eb00207
commit
4e5545af38
17 changed files with 472 additions and 205 deletions
20
src/api/stream/server.ts
Normal file
20
src/api/stream/server.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
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', () => {
|
||||
console.log('yooo');
|
||||
ev.removeListener('stats', onStats);
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue