TsgcWSPServer_sgcEventi › OnRPCAuthentication

OnRPCAuthentication Evento

Generato quando un metodo RPC non è nella lista consentita, permettendo al gestore di autorizzarlo.

Sintassi

property OnRPCAuthentication: TsgcWSRPCAuthenticationEvent;
// TsgcWSRPCAuthenticationEvent = procedure(Connection: TsgcWSConnection; const Method, User, Password: string; var Authenticated: Boolean) of object

Valore predefinito

Note

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".

Esempio

procedure TForm1.oProtocolRPCAuthentication(Connection: TsgcWSConnection;
  const Method, User, Password: string; var Authenticated: Boolean);
begin
  Authenticated := (User = 'admin') and (Password = 'secret');
end;

Torna agli Eventi