TsgcWebSocketHTTPServerEvents › OnFragmented

OnFragmented Event

Fires when a fragment of a message is received (only when Options.FragmentedMessages is frgAll or frgOnlyFragmented).

Syntax

public event TsgcWSFragmentedEventHandler OnFragmented;
// delegate void TsgcWSFragmentedEventHandler(TsgcWSConnection Connection, TMemoryStream Data, TOpCode OpCode, bool Continuation)

Default Value

Remarks

By default (Options.FragmentedMessages = frgOnlyBuffer) the server buffers the fragments of a WebSocket message and raises OnMessage or OnBinary once the full payload has been received. 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.

Example


void OnFragmented(TsgcWSConnection Connection, TMemoryStream Data,
  TOpCode OpCode, bool Continuation)
{
  ShowProgress(Data.Size);
  if (Continuation == false)
    SaveStream(Data);
}

Back to Events