Moved funcs to basEvent

This commit is contained in:
2024-12-28 23:15:00 +01:00
parent 8781bf43a1
commit ff01e41c8f
4 changed files with 14 additions and 127 deletions

View File

@ -10,4 +10,15 @@ export abstract class BaseEvent {
readonly io: Server,
readonly socket: TSocket
) {}
protected emitError(message: string): void {
this.socket.emit('notification', { title: 'Server message', message })
this.logger.error('character:connect error', `Player ${this.socket.userId}: ${message}`)
}
protected handleError(context: string, error: unknown): void {
const errorMessage = error instanceof Error ? error.message : String(error)
this.emitError(`${context}: ${errorMessage}`)
this.logger.error('character:connect error', errorMessage)
}
}