feat: 服務端可以獲取每個客戶端的連接

This commit is contained in:
CrescentLeaf
2025-09-21 16:13:31 +08:00
parent e4c26a07cf
commit 8bcb3e74b6

View File

@@ -33,8 +33,11 @@ export default class ApiManager {
this.event_listeners[name] = func
}
static clients: { [key: string]: { [key: string]: SocketIo.Socket<SocketIo.DefaultEventsMap, SocketIo.DefaultEventsMap, SocketIo.DefaultEventsMap, any> } } = {}
static checkUserIsOnline(userId: string, deviceId: string) {
return this.clients[userId]?.[deviceId] != null
static checkUserIsOnline(userId: string) {
return this.getUserClientSockets(userId) != null
}
static getUserClientSockets(userId: string) {
return this.clients[userId]
}
static initEvents() {
const io = this.socketIoServer