TsgcWSPServer_sgcEventi › OnRPC

OnRPC Evento

Viene attivato quando un client invoca un metodo JSON-RPC su questo server.

Sintassi

property OnRPC: TsgcWSRPCEvent;
// TsgcWSRPCEvent = procedure(Connection: TsgcWSConnection; const ID, Method, Params: string) of object

Valore predefinito

Note

Generato per ogni chiamata che contiene un Id non vuoto e ha superato il controllo RPCAuthentication. Eseguire il metodo e rispondere usando RPCResult (successo) o RPCError (errore), riutilizzando ID affinché il client possa correlare la risposta. Params è il testo JSON grezzo dell'oggetto/array dei parametri.

Esempio

procedure TForm1.oProtocolRPC(Connection: TsgcWSConnection;
  const ID, Method, Params: string);
begin
  if Method = 'ping' then
    oProtocol.RPCResult(ID, '"pong"')
  else
    oProtocol.RPCError(ID, -32601, 'Method not found');
end;

Torna agli Eventi