diff --git a/tests/monster_test_grpc.d.ts b/tests/monster_test_grpc.d.ts new file mode 100644 index 000000000..9afbaa8fd --- /dev/null +++ b/tests/monster_test_grpc.d.ts @@ -0,0 +1,93 @@ +// Generated GRPC code for FlatBuffers TS *** DO NOT EDIT *** +import * as flatbuffers from 'flatbuffers'; +import { Stat as MyGame_Example_Stat } from './my-game/example/stat'; +import { Monster as MyGame_Example_Monster } from './my-game/example/monster'; + +import * as grpc from 'grpc'; + +interface IMonsterStorageService extends grpc.ServiceDefinition { + Store: IMonsterStorageService_IStore; + Retrieve: IMonsterStorageService_IRetrieve; + GetMaxHitPoint: IMonsterStorageService_IGetMaxHitPoint; + GetMinMaxHitPoints: IMonsterStorageService_IGetMinMaxHitPoints; +} +interface IMonsterStorageService_IStore extends grpc.MethodDefinition { + path: string; // /MyGame.Example.MonsterStorage/Store + requestStream: boolean; // false + responseStream: boolean; // false + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} + +interface IMonsterStorageService_IRetrieve extends grpc.MethodDefinition { + path: string; // /MyGame.Example.MonsterStorage/Retrieve + requestStream: boolean; // false + responseStream: boolean; // true + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} + +interface IMonsterStorageService_IGetMaxHitPoint extends grpc.MethodDefinition { + path: string; // /MyGame.Example.MonsterStorage/GetMaxHitPoint + requestStream: boolean; // true + responseStream: boolean; // false + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} + +interface IMonsterStorageService_IGetMinMaxHitPoints extends grpc.MethodDefinition { + path: string; // /MyGame.Example.MonsterStorage/GetMinMaxHitPoints + requestStream: boolean; // true + responseStream: boolean; // true + requestSerialize: grpc.serialize; + requestDeserialize: grpc.deserialize; + responseSerialize: grpc.serialize; + responseDeserialize: grpc.deserialize; +} + + +export const MonsterStorageService: IMonsterStorageService; + +export interface IMonsterStorageServer { + Store: grpc.handleUnaryCall; + Retrieve: grpc.handleServerStreamingCall; + GetMaxHitPoint: grpc.handleClientStreamingCall; + GetMinMaxHitPoints: grpc.handleBidiStreamingCall; +} + +export interface IMonsterStorageClient { + Store(request: MyGame_Example_Monster, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Stat) => void): grpc.ClientUnaryCall; + Store(request: MyGame_Example_Monster, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Stat) => void): grpc.ClientUnaryCall; + Store(request: MyGame_Example_Monster, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Stat) => void): grpc.ClientUnaryCall; + Retrieve(request: MyGame_Example_Stat, metadata: grpc.Metadata): grpc.ClientReadableStream; + Retrieve(request: MyGame_Example_Stat, options: Partial): grpc.ClientReadableStream; + GetMaxHitPoint(callback: (error: grpc.ServiceError | null, response: MyGame_Example_Monster) => void): grpc.ClientWritableStream; + GetMaxHitPoint(metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Monster) => void): grpc.ClientWritableStream; + GetMaxHitPoint(options: Partial, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Monster) => void): grpc.ClientWritableStream; + GetMaxHitPoint(metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Monster) => void): grpc.ClientWritableStream; + GetMinMaxHitPoints(): grpc.ClientDuplexStream; + GetMinMaxHitPoints(options: Partial): grpc.ClientDuplexStream; + GetMinMaxHitPoints(metadata: grpc.Metadata, options?: Partial): grpc.ClientDuplexStream; +} + +export class MonsterStorageClient extends grpc.Client implements IMonsterStorageClient { + constructor(address: string, credentials: grpc.ChannelCredentials, options?: object); public Store(request: MyGame_Example_Monster, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Stat) => void): grpc.ClientUnaryCall; + public Store(request: MyGame_Example_Monster, metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Stat) => void): grpc.ClientUnaryCall; + public Store(request: MyGame_Example_Monster, metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Stat) => void): grpc.ClientUnaryCall; + public Retrieve(request: MyGame_Example_Stat, metadata: grpc.Metadata): grpc.ClientReadableStream; + public Retrieve(request: MyGame_Example_Stat, options: Partial): grpc.ClientReadableStream; + public GetMaxHitPoint(callback: (error: grpc.ServiceError | null, response: MyGame_Example_Monster) => void): grpc.ClientWritableStream; + public GetMaxHitPoint(metadata: grpc.Metadata, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Monster) => void): grpc.ClientWritableStream; + public GetMaxHitPoint(options: Partial, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Monster) => void): grpc.ClientWritableStream; + public GetMaxHitPoint(metadata: grpc.Metadata, options: Partial, callback: (error: grpc.ServiceError | null, response: MyGame_Example_Monster) => void): grpc.ClientWritableStream; + public GetMinMaxHitPoints(): grpc.ClientDuplexStream; + public GetMinMaxHitPoints(options: Partial): grpc.ClientDuplexStream; + public GetMinMaxHitPoints(metadata: grpc.Metadata, options?: Partial): grpc.ClientDuplexStream; +} + diff --git a/tests/monster_test_grpc.js b/tests/monster_test_grpc.js new file mode 100644 index 000000000..e86085460 --- /dev/null +++ b/tests/monster_test_grpc.js @@ -0,0 +1,80 @@ +// Generated GRPC code for FlatBuffers TS *** DO NOT EDIT *** +import * as flatbuffers from 'flatbuffers'; +import { Stat as MyGame_Example_Stat } from './my-game/example/stat'; +import { Monster as MyGame_Example_Monster } from './my-game/example/monster'; + +var grpc = require('grpc'); + +function serialize_MyGame_Example_Stat(buffer_args) { + if (!(buffer_args instanceof MyGame_Example_Stat)) { + throw new Error('Expected argument of type Stat'); + } + return buffer_args.serialize(); +} + +function deserialize_MyGame_Example_Stat(buffer) { + return MyGame_Example_Stat.getRootAsStat(new flatbuffers.ByteBuffer(buffer)) +} + + +function serialize_MyGame_Example_Monster(buffer_args) { + if (!(buffer_args instanceof MyGame_Example_Monster)) { + throw new Error('Expected argument of type Monster'); + } + return buffer_args.serialize(); +} + +function deserialize_MyGame_Example_Monster(buffer) { + return MyGame_Example_Monster.getRootAsMonster(new flatbuffers.ByteBuffer(buffer)) +} + + + + +var MonsterStorageService = exports.MonsterStorageService = { + Store: { + path: '/MyGame.Example.MonsterStorage/Store', + requestStream: false, + responseStream: false, + requestType: flatbuffers.ByteBuffer, + responseType: MyGame_Example_Stat, + requestSerialize: serialize_MyGame_Example_Monster, + requestDeserialize: deserialize_MyGame_Example_Monster, + responseSerialize: serialize_MyGame_Example_Stat, + responseDeserialize: deserialize_MyGame_Example_Stat, + }, + Retrieve: { + path: '/MyGame.Example.MonsterStorage/Retrieve', + requestStream: false, + responseStream: true, + requestType: flatbuffers.ByteBuffer, + responseType: MyGame_Example_Monster, + requestSerialize: serialize_MyGame_Example_Stat, + requestDeserialize: deserialize_MyGame_Example_Stat, + responseSerialize: serialize_MyGame_Example_Monster, + responseDeserialize: deserialize_MyGame_Example_Monster, + }, + GetMaxHitPoint: { + path: '/MyGame.Example.MonsterStorage/GetMaxHitPoint', + requestStream: true, + responseStream: false, + requestType: flatbuffers.ByteBuffer, + responseType: MyGame_Example_Stat, + requestSerialize: serialize_MyGame_Example_Monster, + requestDeserialize: deserialize_MyGame_Example_Monster, + responseSerialize: serialize_MyGame_Example_Stat, + responseDeserialize: deserialize_MyGame_Example_Stat, + }, + GetMinMaxHitPoints: { + path: '/MyGame.Example.MonsterStorage/GetMinMaxHitPoints', + requestStream: true, + responseStream: true, + requestType: flatbuffers.ByteBuffer, + responseType: MyGame_Example_Stat, + requestSerialize: serialize_MyGame_Example_Monster, + requestDeserialize: deserialize_MyGame_Example_Monster, + responseSerialize: serialize_MyGame_Example_Stat, + responseDeserialize: deserialize_MyGame_Example_Stat, + }, +}; +exports.MonsterStorageClient = grpc.makeGenericClientConstructor(MonsterStorageService);