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 type { UUID } from '#application/types'
import Logger, { LoggerType } from '#application/logger'
@ -61,7 +62,7 @@ class CharacterTeleportService {
// If the current map is the target map and we are not joining, send move event
if (currentMapId === options.targetMapId && !options.isInitialJoin) {
// If the current map is the target map, send move event
io.in(currentMapId).emit('map:character:move', {
io.in(currentMapId).emit(SocketEvent.MAP_CHARACTER_MOVE, {
characterId: mapCharacter.character.id,
positionX: options.targetX,
positionY: options.targetY,
@ -75,7 +76,7 @@ class CharacterTeleportService {
if (currentMapId) {
socket.leave(currentMapId)
MapManager.removeCharacter(characterId)
io.in(currentMapId).emit('map:character:leave', characterId)
io.in(currentMapId).emit(SocketEvent.MAP_CHARACTER_LEAVE, characterId)
}
// Join new map
@ -86,8 +87,8 @@ class CharacterTeleportService {
await mapRepository.getEntityManager().populate(map!, mapRepository.POPULATE_TELEPORT as any)
// Notify clients
io.in(options.targetMapId).emit('map:character:join', mapCharacter)
socket.emit('map:character:teleport', {
io.in(options.targetMapId).emit(SocketEvent.MAP_CHARACTER_JOIN, mapCharacter)
socket.emit(SocketEvent.MAP_CHARACTER_TELEPORT, {
mapId: options.targetMapId,
characters: targetMap.getCharactersInMap()
})