TsgcWSPServer_sgc › 이벤트 › OnRPC
클라이언트가 이 서버에서 JSON-RPC 메서드를 호출할 때 발생합니다.
property OnRPC: TsgcWSRPCEvent;
// TsgcWSRPCEvent = procedure(Connection: TsgcWSConnection; const ID, Method, Params: string) of object
—
비어 있지 않은 Id를 가지고 있고 RPCAuthentication 검사를 통과한 모든 호출에 대해 발생합니다. 메서드를 실행하고 RPCResult(성공) 또는 RPCError(실패)를 사용하여 응답하되, 클라이언트가 응답을 상관시킬 수 있도록 ID를 재사용하십시오. Params는 매개변수 객체/배열의 원시 JSON 텍스트입니다.
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;