TsgcWSPServer_WAMPEvents › OnBeforeCancelCall

OnBeforeCancelCall Event

Fires when a client asks to cancel an in-flight RPC, giving the server the chance to honour or refuse the request.

Syntax

property OnBeforeCancelCall: TsgcWSBeforeCancelCallEvent;
// TsgcWSBeforeCancelCallEvent = procedure(Connection: TsgcWSConnection; const CallId: string; var Cancel: Boolean) of object

Default Value

Remarks

Raised when a CALLCANCEL frame arrives for a previously-dispatched CALL identified by CallId. Cancel is True by default, which tells the broker to stop delivering progress results for that call and to expect a terminal CallError from the application. Set Cancel to False to refuse the cancellation — the RPC will keep running and its final CallResult or CallError will still be sent back. Typical uses are long-running queries, batch jobs or background RPCs where the caller changed its mind.

Example


procedure TForm1.WAMPServerBeforeCancelCall(Connection: TsgcWSConnection;
  const CallId: string; var Cancel: Boolean);
begin
  // honour the cancel and respond with an error so the caller resolves
  Cancel := True;
  WSPServerWAMP1.CallError(Connection, CallId,
    'http://example.com/errors/cancelled', 'call cancelled by client');
end;

Back to Events