mirror of
https://github.com/whyour/qinglong.git
synced 2026-07-01 04:40:38 +08:00
添加系统更新操作和设置删除日志频率
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import { Service, Inject } from 'typedi';
|
||||
import winston from 'winston';
|
||||
import { Connection } from 'sockjs';
|
||||
|
||||
@Service()
|
||||
export default class SockService {
|
||||
private clients: Connection[] = [];
|
||||
|
||||
constructor(@Inject('logger') private logger: winston.Logger) {}
|
||||
|
||||
public getClients() {
|
||||
return this.clients;
|
||||
}
|
||||
|
||||
public addClient(conn: Connection) {
|
||||
if (this.clients.indexOf(conn) === -1) {
|
||||
this.clients.push(conn);
|
||||
}
|
||||
}
|
||||
|
||||
public removeClient(conn: Connection) {
|
||||
const index = this.clients.indexOf(conn);
|
||||
if (index !== -1) {
|
||||
this.clients.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public sendMessage(msg: string) {
|
||||
this.clients.forEach((x) => {
|
||||
x.write(msg);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user