forked from noxious/server
New method for events + TP work
This commit is contained in:
@ -14,7 +14,8 @@ const logger = pino({
|
||||
return { level: label.toUpperCase() }
|
||||
}
|
||||
},
|
||||
timestamp: pino.stdTimeFunctions.isoTime
|
||||
timestamp: pino.stdTimeFunctions.isoTime,
|
||||
base: null // This will prevent hostname and pid from being included
|
||||
})
|
||||
|
||||
export default logger
|
||||
|
29
src/utilities/socketEmitter.ts
Normal file
29
src/utilities/socketEmitter.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import { Server } from 'socket.io'
|
||||
import { TSocket, ExtendedCharacter } from './types'
|
||||
|
||||
export class SocketEmitter {
|
||||
constructor(
|
||||
private readonly io: Server,
|
||||
private readonly socket: TSocket
|
||||
) {}
|
||||
|
||||
public emitMoveError(message: string): void {
|
||||
this.socket.emit('character:moveError', message)
|
||||
}
|
||||
|
||||
public emitCharacterMove(character: ExtendedCharacter): void {
|
||||
this.io.in(character.zoneId.toString()).emit('character:move', character)
|
||||
}
|
||||
|
||||
public emitCharacterLeave(character: ExtendedCharacter, zoneId: number): void {
|
||||
this.io.to(zoneId.toString()).emit('zone:character:leave', character)
|
||||
}
|
||||
|
||||
public emitCharacterJoin(character: ExtendedCharacter): void {
|
||||
this.io.to(character.zoneId.toString()).emit('zone:character:join', character)
|
||||
}
|
||||
|
||||
public emitCharacterDataUpdated(character: ExtendedCharacter): void {
|
||||
this.socket.emit('character:dataUpdated', character)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user