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 type { MapCacheT } from '#entities/map'
|
||||
|
||||
import { BaseEvent } from '#application/base/baseEvent'
|
||||
@ -11,7 +12,7 @@ type Payload = {
|
||||
|
||||
export default class MapCreateEvent extends BaseEvent {
|
||||
public listen(): void {
|
||||
this.socket.on('gm:map:create', this.handleEvent.bind(this))
|
||||
this.socket.on(SocketEvent.GM_MAP_CREATE, this.handleEvent.bind(this))
|
||||
}
|
||||
|
||||
private async handleEvent(data: Payload, callback: (response: MapCacheT | false) => void): Promise<void> {
|
||||
@ -21,12 +22,12 @@ export default class MapCreateEvent extends BaseEvent {
|
||||
this.logger.info(`GM ${(await this.getCharacter())!.getId()} has created a new map via map editor.`)
|
||||
|
||||
if (data.name === '') {
|
||||
this.socket.emit('notification', { title: 'Error', message: 'Map name cannot be empty.' })
|
||||
this.socket.emit(SocketEvent.NOTIFICATION, { title: 'Error', message: 'Map name cannot be empty.' })
|
||||
return callback(false)
|
||||
}
|
||||
|
||||
if (data.width < 1 || data.height < 1) {
|
||||
this.socket.emit('notification', { title: 'Error', message: 'Map width and height must be greater than 0.' })
|
||||
this.socket.emit(SocketEvent.NOTIFICATION, { title: 'Error', message: 'Map width and height must be greater than 0.' })
|
||||
return callback(false)
|
||||
}
|
||||
|
||||
@ -41,7 +42,7 @@ export default class MapCreateEvent extends BaseEvent {
|
||||
return callback(await map.cache())
|
||||
} catch (error: any) {
|
||||
this.logger.error('gm:map:create error', error.message)
|
||||
this.socket.emit('notification', { message: 'Failed to create map.' })
|
||||
this.socket.emit(SocketEvent.NOTIFICATION, { message: 'Failed to create map.' })
|
||||
return callback(false)
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { SocketEvent } from '#application/enums';
|
||||
import type { UUID } from '#application/types'
|
||||
|
||||
import { BaseEvent } from '#application/base/baseEvent'
|
||||
@ -9,7 +10,7 @@ type Payload = {
|
||||
|
||||
export default class MapDeleteEvent extends BaseEvent {
|
||||
public listen(): void {
|
||||
this.socket.on('gm:map:delete', this.handleEvent.bind(this))
|
||||
this.socket.on(SocketEvent.GM_MAP_DELETE, this.handleEvent.bind(this))
|
||||
}
|
||||
|
||||
private async handleEvent(data: Payload, callback: (response: boolean) => void): Promise<void> {
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { SocketEvent } from '#application/enums';
|
||||
import type { UUID } from '#application/types'
|
||||
|
||||
import { BaseEvent } from '#application/base/baseEvent'
|
||||
@ -10,7 +11,7 @@ interface IPayload {
|
||||
|
||||
export default class MapRequestEvent extends BaseEvent {
|
||||
public listen(): void {
|
||||
this.socket.on('gm:map:request', this.handleEvent.bind(this))
|
||||
this.socket.on(SocketEvent.GM_MAP_REQUEST, this.handleEvent.bind(this))
|
||||
}
|
||||
|
||||
private async handleEvent(data: IPayload, callback: (response: Map | null) => void): Promise<void> {
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { SocketEvent } from '#application/enums';
|
||||
import type { UUID } from '#application/types'
|
||||
|
||||
import { BaseEvent } from '#application/base/baseEvent'
|
||||
@ -34,7 +35,7 @@ interface IPayload {
|
||||
|
||||
export default class MapUpdateEvent extends BaseEvent {
|
||||
public listen(): void {
|
||||
this.socket.on('gm:map:update', this.handleEvent.bind(this))
|
||||
this.socket.on(SocketEvent.GM_MAP_UPDATE, this.handleEvent.bind(this))
|
||||
}
|
||||
|
||||
private async handleEvent(data: IPayload, callback: (response: Map | null) => void): Promise<void> {
|
||||
|
Reference in New Issue
Block a user