Mass replace parameter order (socket,io)>(io,socket), worked on queueing system
This commit is contained in:
44
src/socketEvents/gameMaster/assetManager/tile/update.ts
Normal file
44
src/socketEvents/gameMaster/assetManager/tile/update.ts
Normal file
@ -0,0 +1,44 @@
|
||||
import { Server } from 'socket.io'
|
||||
import { TSocket } from '../../../../utilities/types'
|
||||
import prisma from '../../../../utilities/prisma'
|
||||
import CharacterManager from '../../../../managers/characterManager'
|
||||
import characterRepository from '../../../../repositories/characterRepository'
|
||||
|
||||
type Payload = {
|
||||
id: string
|
||||
name: string
|
||||
tags: string[]
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle game master tile update event
|
||||
* @param socket
|
||||
* @param io
|
||||
*/
|
||||
export default function (io: Server, socket: TSocket) {
|
||||
socket.on('gm:tile:update', async (data: Payload, callback: (success: boolean) => void) => {
|
||||
const character = await characterRepository.getById(socket.characterId as number)
|
||||
if (!character) return callback(false)
|
||||
|
||||
if (character.role !== 'gm') {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const Tile = await prisma.tile.update({
|
||||
where: {
|
||||
id: data.id
|
||||
},
|
||||
data: {
|
||||
name: data.name,
|
||||
tags: data.tags
|
||||
}
|
||||
})
|
||||
|
||||
callback(true)
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
callback(false)
|
||||
}
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user