forked from noxious/server
Mass replace parameter order (socket,io)>(io,socket), worked on queueing system
This commit is contained in:
@ -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}`)
|
||||
}
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user