TsgcWSPServer_sgc › Events › OnRPCAuthentication
Wywoływane, gdy metoda RPC nie znajduje się na liście dozwolonych, co pozwala programowi obsługi na jej autoryzację.
property OnRPCAuthentication: TsgcWSRPCAuthenticationEvent;
// TsgcWSRPCAuthenticationEvent = procedure(Connection: TsgcWSConnection; const Method, User, Password: string; var Authenticated: Boolean) of object
—
Wywoływane tylko wtedy, gdy właściwość RPCAuthentication.Enabled jest ustawiona na True, a nazwa metody nie pojawia się w RPCAuthentication.Methods ani jako zwykła nazwa, ani w formacie metoda=użytkownik. Procedura obsługi otrzymuje żądaną Method oraz User i Password podane podczas uzgadniania WebSocket; ustawienie parametru Authenticated na True powoduje wywołanie zdarzenia OnRPC, pozostawienie False skutkuje odpowiedzią serwera z błędem JSON-RPC "Method not found".
procedure TForm1.oProtocolRPCAuthentication(Connection: TsgcWSConnection;
const Method, User, Password: string; var Authenticated: Boolean);
begin
Authenticated := (User = 'admin') and (Password = 'secret');
end;