import { Server, ServerUnaryCall, sendUnaryData } from '@grpc/grpc-js' import { Character, GetCharacterRequest, CreateCharacterRequest, } from './proto/character' import { characterManagerDefinition } from "./proto/character.grpc-server" export function initCharacterService(server: Server) { server.addService(characterManagerDefinition, { createCharacter: createCharacter_Call, getCharacter: getCharacter_Call, }) } function createCharacter_Call(call: ServerUnaryCall, callback: sendUnaryData) { callback(null, createCharacter(call.request)) } function createCharacter(request: CreateCharacterRequest): Character { return { playerName: "test player", characterName: "test character", characterAlias: ["test alias"] } } function getCharacter_Call(call: ServerUnaryCall, callback: sendUnaryData) { callback(null, getCharacter(call.request)) } function getCharacter(request: GetCharacterRequest): Character { return { playerName: "test player", characterName: "test character", characterAlias: ["test alias"] } }