Replaced all event names with numbers for less bandwidth usage
This commit is contained in:
@ -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', {
|
||||
|
Reference in New Issue
Block a user