mirror of
https://activitypub.software/TransFem-org/Sharkey.git
synced 2024-12-17 06:59:01 +01:00
b9cb6d1c10
将来ESMに移行しやすいように Related: #7658 なんかmochaが起動しなくなってるけど理由不明 すぐ直したい
41 lines
843 B
TypeScript
41 lines
843 B
TypeScript
import autobind from 'autobind-decorator';
|
|
import Xev from 'xev';
|
|
import Channel from '../channel.js';
|
|
|
|
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,
|
|
length: body.length
|
|
});
|
|
break;
|
|
}
|
|
}
|
|
|
|
@autobind
|
|
public dispose() {
|
|
ev.removeListener('queueStats', this.onStats);
|
|
}
|
|
}
|