TsgcWebSocketClient › Events › OnBinary
Fires every time the server sends a binary message to the client.
public event TsgcWSBinaryEventHandler OnBinary;
// delegate void TsgcWSBinaryEventHandler(TsgcWSConnection Connection, TMemoryStream Data)
—
OnBinary is raised once the full binary payload has been received and buffered. The Data parameter exposes the decoded bytes as a TMemoryStream positioned at 0; read it immediately because the stream is owned by the client and becomes invalid after the handler returns. By default NotifyEvents is neAsynchronous, so OnBinary is synchronized with the main thread and it is safe to update UI controls from the handler; switch to neNoSync if you need to avoid synchronization and handle thread-safety yourself. If Options.FragmentedMessages is frgOnlyFragmented the event is not fired and OnFragmented is used instead.
private void OnBinary(TsgcWSConnection Connection, byte[] Bytes)
{
MemoryStream stream = new MemoryStream(Bytes);
pictureBox1.Image = new Bitmap(stream);
}