TsgcWebSocketProxyServer › Events › OnFragmented
Fires when a fragment of a message is received from a downstream client (only when Options.FragmentedMessages is frgAll or frgOnlyFragmented).
property OnFragmented: TsgcWSFragmentedEvent;
// TsgcWSFragmentedEvent = procedure(Connection: TsgcWSConnection; const Data: TMemoryStream; const OpCode: TOpCode; const Continuation: Boolean) of object
—
By default (Options.FragmentedMessages = frgOnlyBuffer) the proxy buffers the fragments of a downstream message and raises OnMessage or OnBinary once the full payload has been received and forwards it upstream. Set FragmentedMessages to frgOnlyFragmented to receive only OnFragmented per fragment, or to frgAll to receive OnFragmented per fragment and then OnMessage/OnBinary when the message is complete. The Data parameter is a TMemoryStream with the bytes of the current fragment, OpCode indicates the original frame type (text, binary, continuation...), and Continuation is True while more fragments are expected and False on the final fragment. This event is useful to report progress of large uploads being proxied.
procedure OnFragmented(Connection: TsgcWSConnection; const Data: TMemoryStream;
const OpCode: TOpCode; const Continuation: Boolean);
begin
ShowProgress(Data.Size);
if not Continuation then
SaveStream(Data);
end;