Socket event enum enhancement
This commit is contained in:
parent
bfba7197b7
commit
4ac1e8824d
@ -1,4 +1,6 @@
|
|||||||
export enum SocketEvent {
|
export enum SocketEvent {
|
||||||
|
CONNECT_ERROR = 'connect_error',
|
||||||
|
RECONNECT_FAILED = 'reconnect_failed',
|
||||||
CLOSE = '52',
|
CLOSE = '52',
|
||||||
DATA = '51',
|
DATA = '51',
|
||||||
CHARACTER_CONNECT = '50',
|
CHARACTER_CONNECT = '50',
|
||||||
@ -35,7 +37,7 @@ export enum SocketEvent {
|
|||||||
GM_MAP_REQUEST = '19',
|
GM_MAP_REQUEST = '19',
|
||||||
GM_MAP_UPDATE = '18',
|
GM_MAP_UPDATE = '18',
|
||||||
MAP_CHARACTER_MOVEERROR = '17',
|
MAP_CHARACTER_MOVEERROR = '17',
|
||||||
DISCONNECT = '16',
|
DISCONNECT = 'disconnect',
|
||||||
USER_DISCONNECT = '15',
|
USER_DISCONNECT = '15',
|
||||||
LOGIN = '14',
|
LOGIN = '14',
|
||||||
LOGGED_IN = '13',
|
LOGGED_IN = '13',
|
||||||
@ -43,7 +45,7 @@ export enum SocketEvent {
|
|||||||
DATE = '11',
|
DATE = '11',
|
||||||
FAILED = '10',
|
FAILED = '10',
|
||||||
COMPLETED = '9',
|
COMPLETED = '9',
|
||||||
CONNECTION = '8',
|
CONNECTION = 'connection',
|
||||||
WEATHER = '7',
|
WEATHER = '7',
|
||||||
CHARACTER_DISCONNECT = '6',
|
CHARACTER_DISCONNECT = '6',
|
||||||
MAP_CHARACTER_ATTACK = '5',
|
MAP_CHARACTER_ATTACK = '5',
|
||||||
|
@ -4,7 +4,7 @@ import MapManager from '@/managers/mapManager'
|
|||||||
|
|
||||||
export default class DisconnectEvent extends BaseEvent {
|
export default class DisconnectEvent extends BaseEvent {
|
||||||
public listen(): void {
|
public listen(): void {
|
||||||
this.socket.on('disconnect', this.handleEvent.bind(this))
|
this.socket.on(SocketEvent.DISCONNECT, this.handleEvent.bind(this))
|
||||||
}
|
}
|
||||||
|
|
||||||
private async handleEvent(): Promise<void> {
|
private async handleEvent(): Promise<void> {
|
||||||
|
@ -6,6 +6,7 @@ import Storage from '@/application/storage'
|
|||||||
import type { TSocket, UUID } from '@/application/types'
|
import type { TSocket, UUID } from '@/application/types'
|
||||||
import { Authentication } from '@/middleware/authentication'
|
import { Authentication } from '@/middleware/authentication'
|
||||||
import { Server as SocketServer } from 'socket.io'
|
import { Server as SocketServer } from 'socket.io'
|
||||||
|
import {SocketEvent} from "@/application/enums";
|
||||||
|
|
||||||
class SocketManager {
|
class SocketManager {
|
||||||
private io: SocketServer | null = null
|
private io: SocketServer | null = null
|
||||||
@ -21,7 +22,7 @@ class SocketManager {
|
|||||||
this.io.use(Authentication)
|
this.io.use(Authentication)
|
||||||
|
|
||||||
// Set up connection handler
|
// Set up connection handler
|
||||||
this.io.on('connection', this.handleConnection.bind(this))
|
this.io.on(SocketEvent.CONNECTION, this.handleConnection.bind(this))
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user