2019-03-10 19:16:33 +09:00
|
|
|
import autobind from 'autobind-decorator';
|
|
|
|
import Xev from 'xev';
|
2021-08-19 21:55:45 +09:00
|
|
|
import Channel from '../channel';
|
2019-03-10 19:16:33 +09:00
|
|
|
|
|
|
|
const ev = new Xev();
|
|
|
|
|
|
|
|
export default class extends Channel {
|
|
|
|
public readonly chName = 'queueStats';
|
|
|
|
public static shouldShare = true;
|
|
|
|
public static requireCredential = false;
|
|
|
|
|
|
|
|
@autobind
|
|
|
|
public async init(params: any) {
|
|
|
|
ev.addListener('queueStats', this.onStats);
|
|
|
|
}
|
|
|
|
|
|
|
|
@autobind
|
|
|
|
private onStats(stats: any) {
|
|
|
|
this.send('stats', stats);
|
|
|
|
}
|
|
|
|
|
|
|
|
@autobind
|
|
|
|
public onMessage(type: string, body: any) {
|
|
|
|
switch (type) {
|
|
|
|
case 'requestLog':
|
|
|
|
ev.once(`queueStatsLog:${body.id}`, statsLog => {
|
|
|
|
this.send('statsLog', statsLog);
|
|
|
|
});
|
|
|
|
ev.emit('requestQueueStatsLog', {
|
|
|
|
id: body.id,
|
2021-12-09 23:58:30 +09:00
|
|
|
length: body.length,
|
2019-03-10 19:16:33 +09:00
|
|
|
});
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@autobind
|
|
|
|
public dispose() {
|
|
|
|
ev.removeListener('queueStats', this.onStats);
|
|
|
|
}
|
|
|
|
}
|