TsgcWebSocketHTTPServer › Events › OnBinary
Fires every time a client sends a binary message and it is received by the server.
public event TsgcWSBinaryEventHandler OnBinary;
// delegate void TsgcWSBinaryEventHandler(TsgcWSConnection Connection, TMemoryStream Data)
—
OnBinary is raised once a full binary payload has been received and buffered from a WebSocket client. The Data parameter exposes the decoded bytes as a TMemoryStream positioned at 0; read it inside the handler because the stream is owned by the server 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 touch UI controls; switch to neNoSync to dispatch on the connection thread when throughput matters. If Options.FragmentedMessages is frgOnlyFragmented the event is not raised and OnFragmented is used instead.
private void OnBinary(TsgcWSConnection Connection, byte[] Bytes)
{
MemoryStream stream = new MemoryStream(Bytes);
pictureBox1.Image = new Bitmap(stream);
}