TsgcWSPServer_sgc › Events › OnRPC
Fires when a client invokes a JSON-RPC method on this server.
property OnRPC: TsgcWSRPCEvent;
// TsgcWSRPCEvent = procedure(Connection: TsgcWSConnection; const ID, Method, Params: string) of object
—
Raised for every call that carries a non-empty Id and has passed the RPCAuthentication check. Execute the method and reply using RPCResult (success) or RPCError (failure), reusing ID so the client can correlate the response. Params is the raw JSON text of the parameter object/array.
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;