TsgcWSPServer_sgc › Eventi › OnRPCAuthentication
Generato quando un metodo RPC non è nella lista consentita, permettendo al gestore di autorizzarlo.
property OnRPCAuthentication: TsgcWSRPCAuthenticationEvent;
// TsgcWSRPCAuthenticationEvent = procedure(Connection: TsgcWSConnection; const Method, User, Password: string; var Authenticated: Boolean) of object
—
Si attiva solo quando RPCAuthentication.Enabled è True e il nome del metodo non compare in RPCAuthentication.Methods né da solo né come method=user. Il gestore riceve il Method richiesto più lo User e la Password presentati durante l'handshake WebSocket; imposti Authenticated a True per dispatchare OnRPC, oppure lo lasci False per far rispondere il server con un errore 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;