format & lint

This commit is contained in:
2025-01-01 04:48:30 +01:00
parent 495e9f192e
commit 9c28b10383
12 changed files with 48 additions and 55 deletions

View File

@ -1,13 +1,14 @@
import { Server as SocketServer } from 'socket.io'
import fs from 'fs'
import { pathToFileURL } from 'url'
import { Server as HTTPServer } from 'http'
import { Application } from 'express'
import { pathToFileURL } from 'url'
import { Application } from 'express'
import { Server as SocketServer } from 'socket.io'
import config from '#application/config'
import Logger, { LoggerType } from '#application/logger'
import { getAppPath } from '#application/storage'
import { TSocket } from '#application/types'
import config from '#application/config'
import { Authentication } from '#middleware/authentication'
class SocketManager {
@ -105,18 +106,20 @@ class SocketManager {
* Emit event to specific room
*/
public emitToRoom(room: string, event: string, ...args: any[]): void {
this.getIO().to(room).emit(event, ...args)
this.getIO()
.to(room)
.emit(event, ...args)
}
public getSocketByUserId(userId: number): TSocket | undefined {
const sockets = Array.from(this.getIO().sockets.sockets.values());
return sockets.find((socket: TSocket) => socket.userId === userId);
const sockets = Array.from(this.getIO().sockets.sockets.values())
return sockets.find((socket: TSocket) => socket.userId === userId)
}
public getSocketByCharacterId(characterId: number): TSocket | undefined {
const sockets = Array.from(this.getIO().sockets.sockets.values());
return sockets.find((socket: TSocket) => socket.characterId === characterId);
const sockets = Array.from(this.getIO().sockets.sockets.values())
return sockets.find((socket: TSocket) => socket.characterId === characterId)
}
}
export default new SocketManager()
export default new SocketManager()