TsgcWSPServer_WAMP › 事件 › OnBeforeCancelCall
当客户端请求取消正在进行的 RPC 时触发,服务器有机会接受或拒绝该请求。
property OnBeforeCancelCall: TsgcWSBeforeCancelCallEvent;
// TsgcWSBeforeCancelCallEvent = procedure(Connection: TsgcWSConnection; const CallId: string; var Cancel: Boolean) of object
—
当 CALLCANCEL 帧到达,用于之前由 CallId 标识的已分发 CALL 时引发。默认情况下 Cancel 为 True,这告知代理停止为该调用传递渐进式结果,并期待来自应用程序的终止 CallError。将 Cancel 设置为 False 以拒绝取消——RPC 将继续运行,其最终的 CallResult 或 CallError 仍将发回。典型用途是长时间运行的查询、批处理作业或调用者改变主意的后台 RPC。
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;