TsgcWSPServer_WAMPMethods › CallProgressResult

CallProgressResult Method

Sends an intermediate (progressive) result chunk to the caller while the RPC is still running; subsequent chunks or a final CallResult are expected.

Syntax

procedure CallProgressResult(const aCallId: String; const aResult: String = '');

Parameters

NameTypeDescription
aCallIdconst StringIdentifier generated by the client when the remote procedure was invoked. The call remains pending after sending a progress chunk, so the same aCallId is reused for every additional chunk and for the final CallResult.
aResultconst StringPartial payload for this chunk. Any string value is allowed (number, text, JSON fragment, etc.); the caller receives the chunks in the same order they are sent.

Remarks

Use this method when a single RPC produces more than one piece of data (streaming responses, paged results, long-running calculations, etc.). Each invocation writes a WAMP CALL_PROGRESS_RESULT frame to the caller but, unlike CallResult, it does not remove the call from the pending list: the server must eventually finish the exchange by calling CallResult (success) or CallError (failure) with the same aCallId. If aCallId does not correspond to a pending call the method silently does nothing. Example: for a procedure that yields 20 items, send items 1..19 with CallProgressResult and item 20 with CallResult.

Example

procedure TForm1.sgcWSPServer_WAMP1Call(Connection: TsgcWSConnection;
  const CallId, ProcURI: string; Arguments: TStringList);
var
  i: Integer;
begin
  if ProcURI = 'com.example.stream' then
  begin
    for i := 1 to 19 do
      sgcWSPServer_WAMP1.CallProgressResult(CallId, IntToStr(i));
    sgcWSPServer_WAMP1.CallResult(CallId, '20');
  end;
end;

Back to Methods