Replaced all event names with numbers for less bandwidth usage

This commit is contained in:
2025-02-11 23:13:15 +01:00
parent 5f2c7a09b1
commit dd1cc795de
26 changed files with 191 additions and 197 deletions

View File

@ -1,3 +1,4 @@
import { SocketEvent } from '@/application/enums';
import config from '@/application/config'
import type { Character, Notification, User, WorldSettings } from '@/application/types'
import { useCookies } from '@vueuse/integrations/useCookies'
@ -85,10 +86,10 @@ export const useGameStore = defineStore('game', {
})
// Let the server know the user is logged in
this.connection.emit('login')
this.connection.emit(SocketEvent.LOGIN)
// set user
this.connection.on('logged_in', (user: User) => {
this.connection.on(SocketEvent.LOGGED_IN, (user: User) => {
this.setUser(user)
})
@ -98,7 +99,7 @@ export const useGameStore = defineStore('game', {
})
// Listen for new date from socket
this.connection.on('date', (data: Date) => {
this.connection.on(SocketEvent.DATE, (data: Date) => {
this.world.date = new Date(data)
})
},
@ -106,7 +107,7 @@ export const useGameStore = defineStore('game', {
// Remove event listeners
this.connection?.off('connect_error')
this.connection?.off('reconnect_failed')
this.connection?.off('date')
this.connection?.off(SocketEvent.DATE)
this.connection?.disconnect()
useCookies().remove('token', {