サーバーの統計情報をメモリに記憶するようにするなど
This commit is contained in:
parent
726d5a177e
commit
6eff8fde74
5 changed files with 41 additions and 7 deletions
|
@ -11,9 +11,25 @@ export default function(request: websocket.request, connection: websocket.connec
|
|||
}));
|
||||
};
|
||||
|
||||
ev.addListener('stats', onStats);
|
||||
connection.on('message', async data => {
|
||||
const msg = JSON.parse(data.utf8Data);
|
||||
|
||||
switch (msg.type) {
|
||||
case 'requestLog':
|
||||
ev.once('serverStatsLog:' + msg.id, statsLog => {
|
||||
connection.send(JSON.stringify({
|
||||
type: 'statsLog',
|
||||
body: statsLog
|
||||
}));
|
||||
});
|
||||
ev.emit('requestServerStatsLog', msg.id);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
ev.addListener('serverStats', onStats);
|
||||
|
||||
connection.on('close', () => {
|
||||
ev.removeListener('stats', onStats);
|
||||
ev.removeListener('serverStats', onStats);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue