TsgcWSPServer_Dataset › Events › OnRPCAuthentication
Fires when an RPC method is not on the allow-list, letting the handler authorise it.
property OnRPCAuthentication: TsgcWSRPCAuthenticationEvent;
// TsgcWSRPCAuthenticationEvent = procedure(Connection: TsgcWSConnection; const Method, User, Password: string; var Authenticated: Boolean) of object
—
Only fires when RPCAuthentication.Enabled is True and the method name does not appear in RPCAuthentication.Methods either bare or as method=user. The handler receives the requested Method plus the User and Password presented on the WebSocket handshake; set Authenticated to True to dispatch OnRPC, or leave it False to have the server answer with a JSON-RPC "Method not found" error.
procedure TForm1.oProtocolRPCAuthentication(Connection: TsgcWSConnection;
const Method, User, Password: string; var Authenticated: Boolean);
begin
Authenticated := (User = 'admin') and (Password = 'secret');
end;