1
0
forked from noxious/server

Replaced all event names with numbers for less bandwidth usage

This commit is contained in:
2025-02-11 23:12:41 +01:00
parent 8b51f6e16a
commit 9e55ac7990
57 changed files with 193 additions and 98 deletions

View File

@@ -1,3 +1,4 @@
import { SocketEvent } from '#application/enums';
import { Server } from 'socket.io'
import type { TSocket } from '#application/types'
@@ -39,14 +40,14 @@ export abstract class BaseEvent {
}
protected emitError(message: string): void {
this.socket.emit('notification', { title: 'Server message', message })
this.socket.emit(SocketEvent.NOTIFICATION, { title: 'Server message', message })
this.logger.error('Base event error', `Player ${this.socket.userId}: ${message}`)
}
protected handleError(context: string, error: unknown): void {
console.log(error)
const errorMessage = error instanceof Error ? error.message : error && typeof error === 'object' && 'toString' in error ? error.toString() : String(error)
this.socket.emit('notification', { title: 'Server message', message: `Server error occured. Please contact the server administrator.` })
this.socket.emit(SocketEvent.NOTIFICATION, { title: 'Server message', message: `Server error occured. Please contact the server administrator.` })
this.logger.error('Base event error', errorMessage)
}
}