feat: 服務端可以獲取每個客戶端的連接
This commit is contained in:
@@ -33,8 +33,11 @@ export default class ApiManager {
|
|||||||
this.event_listeners[name] = func
|
this.event_listeners[name] = func
|
||||||
}
|
}
|
||||||
static clients: { [key: string]: { [key: string]: SocketIo.Socket<SocketIo.DefaultEventsMap, SocketIo.DefaultEventsMap, SocketIo.DefaultEventsMap, any> } } = {}
|
static clients: { [key: string]: { [key: string]: SocketIo.Socket<SocketIo.DefaultEventsMap, SocketIo.DefaultEventsMap, SocketIo.DefaultEventsMap, any> } } = {}
|
||||||
static checkUserIsOnline(userId: string, deviceId: string) {
|
static checkUserIsOnline(userId: string) {
|
||||||
return this.clients[userId]?.[deviceId] != null
|
return this.getUserClientSockets(userId) != null
|
||||||
|
}
|
||||||
|
static getUserClientSockets(userId: string) {
|
||||||
|
return this.clients[userId]
|
||||||
}
|
}
|
||||||
static initEvents() {
|
static initEvents() {
|
||||||
const io = this.socketIoServer
|
const io = this.socketIoServer
|
||||||
|
|||||||
Reference in New Issue
Block a user