1
0
forked from noxious/server

Mass replace parameter order (socket,io)>(io,socket), worked on queueing system

This commit is contained in:
2024-09-21 23:54:52 +02:00
parent 10dc9df8a9
commit 9d6de8a1a9
36 changed files with 206 additions and 121 deletions

View File

@ -1,28 +0,0 @@
import { Server } from 'socket.io'
import { TSocket } from '../../../utilities/types'
import { getArgs, isCommand } from '../../../utilities/chat'
import CharacterRepository from '../../../repositories/characterRepository'
type TypePayload = {
message: string
}
export default function (socket: TSocket, io: Server) {
socket.on('chat:send_message', async (data: TypePayload, callback: (response: boolean) => void) => {
try {
if (!isCommand(data.message, 'alert')) return
const args = getArgs('alert', data.message)
if (!args) return
const character = await CharacterRepository.getByUserAndId(socket.user?.id as number, socket.characterId as number)
if (!character) return
io.emit('notification', { title: 'Message from GM', message: args.join(' ') })
callback(true)
} catch (error: any) {
console.log(`---Error sending message: ${error.message}`)
}
})
}