TsgcWSPServer_sgcEventos › OnRPCAuthentication

OnRPCAuthentication Evento

Se dispara cuando un método RPC no está en la lista de permitidos, permitiendo que el manejador lo autorice.

Sintaxis

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

Valor Predeterminado

Observaciones

Solo se dispara cuando RPCAuthentication.Enabled es True y el nombre del método no aparece en RPCAuthentication.Methods ni directamente ni como method=user. El manejador recibe el Method solicitado junto con el User y la Password presentados en el handshake WebSocket; establezca Authenticated en True para enviar OnRPC, o déjelo en False para que el servidor responda con un error JSON-RPC "Method not found".

Ejemplo

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

Volver a Eventos