17 lines
722 B
TypeScript
17 lines
722 B
TypeScript
import { Socket, Server } from "socket.io";
|
|
import {TSocket} from "../../utilities/Types";
|
|
import {Character} from "@prisma/client";
|
|
import CharacterRepository from "../../repositories/CharacterRepository";
|
|
|
|
export default function CharacterList(socket: TSocket, io: Server) {
|
|
socket.on('character:list', async (data: any) => {
|
|
try {
|
|
console.log('character:list requested');
|
|
const user_id = socket.user?.id as number;
|
|
const characters: Character[] = await CharacterRepository.getByUserId(user_id) as Character[];
|
|
socket.emit('character:list', characters);
|
|
} catch (error: any) {
|
|
console.log('character:list error', error);
|
|
}
|
|
});
|
|
} |