work on the list call

This commit is contained in:
iamBadgers
2025-06-16 00:20:23 -07:00
parent 1f43ff468b
commit a62fe1aba9
3 changed files with 69 additions and 16 deletions

View File

@@ -8,6 +8,8 @@ import {
Character,
GetCharacterRequest,
CreateCharacterRequest,
ListCharacterRequest,
ListCharacterResponse,
} from './proto/character'
import {
@@ -15,6 +17,15 @@ import {
ICharacterManager,
} from './proto/character.grpc-server'
const testCharacter: Character = {
playerName: 'test player',
characterName: 'test character',
characterAlias: ['test alias'],
version: 'test version',
sourceTable: 'source table',
json: 'test json',
}
export class CharacterService {
reflectionService: ReflectionService
characterManager: ICharacterManager
@@ -28,6 +39,7 @@ export class CharacterService {
this.characterManager = {
createCharacter: this.createCharacterCall.bind(this),
getCharacter: this.getCharacterCall.bind(this),
listCharacters: this.listCharactersCall.bind(this),
}
this.databaseService = databaseService
@@ -49,21 +61,27 @@ export class CharacterService {
console.log(newCharacter)
callback(null, {
playerName: newCharacter.playerName,
characterName: newCharacter.characterName,
characterAlias: newCharacter.characterAlias,
})
callback(null, newCharacter)
}
getCharacterCall(
call: ServerUnaryCall<GetCharacterRequest, Character>,
callback: sendUnaryData<Character>,
) {
callback(null, testCharacter)
}
async listCharactersCall(
call: ServerUnaryCall<ListCharacterRequest, ListCharacterResponse>,
callback: sendUnaryData<ListCharacterResponse>,
) {
let characters = await this.databaseService.listCharacters(
call.request.playerName,
call.request.characterName,
)
callback(null, {
playerName: 'test player',
characterName: 'test character',
characterAlias: ['test alias'],
characters,
})
}
}