TGrpcCallContext.Method#
Retorna o nome do método RPC associado à chamada atual.
Declaração#
property Method: String read;Exemplo#
uses
Odisseia.Grpc;
var
Server: TGrpcServer;
Client: TGrpcClient;
Response: String;
function Echo(const Context: TGrpcCallContext;
const RequestJson: String): String;
begin
WriteLn(Context.Method);
Result := RequestJson
end;
begin
Server := TGrpcServer.Create;
Server.Address('127.0.0.1');
Server.Port(50051);
Server.Descriptor('examples/grpc/echo.pb');
Server.Unary('examples.Echo', 'Call', Echo);
Server.Start;
Client := TGrpcClient.Create.Connect;
Response := Client.Unary(
'examples.Echo', 'Call', '{"value":"ok"}', 1000);
Client.Close;
Server.Close
end.Resultado esperado: Call.
O valor corresponde ao método usado no registro do handler e na chamada do cliente.
O valor pertence ao contexto transitório fornecido pelo host e só deve ser consultado durante o callback.