Mass replace parameter order (socket,io)>(io,socket), worked on queueing system
This commit is contained in:
@ -1,47 +0,0 @@
|
||||
import { Server } from 'socket.io'
|
||||
import { TSocket } from '../../../utilities/types'
|
||||
import ZoneRepository from '../../../repositories/zoneRepository'
|
||||
import { Zone } from '@prisma/client'
|
||||
import characterRepository from '../../../repositories/characterRepository'
|
||||
import { gameMasterLogger } from '../../../utilities/logger'
|
||||
|
||||
interface IPayload {
|
||||
zoneId: number
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle game master zone request event
|
||||
* @param socket
|
||||
* @param io
|
||||
*/
|
||||
export default function (socket: TSocket, io: Server) {
|
||||
socket.on('gm:zone_editor:zone:request', async (data: IPayload, callback: (response: Zone) => void) => {
|
||||
const character = await characterRepository.getById(socket.characterId as number);
|
||||
if (!character) return
|
||||
|
||||
if (character.role !== 'gm') {
|
||||
gameMasterLogger.info(`User ${character!.id} tried to request zone but is not a game master.`)
|
||||
return
|
||||
}
|
||||
|
||||
gameMasterLogger.info(`User ${character.id} has requested zone via zone editor.`)
|
||||
|
||||
if (!data.zoneId) {
|
||||
gameMasterLogger.info(`User ${character.id} tried to request zone but did not provide a zone id.`)
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const zone = await ZoneRepository.getById(data.zoneId)
|
||||
|
||||
if (!zone) {
|
||||
gameMasterLogger.info(`User ${character.id} tried to request zone ${data.zoneId} but it does not exist.`)
|
||||
return
|
||||
}
|
||||
|
||||
callback(zone)
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user