TsgcWebSocketClient | Receive Binary Messages

When the client receives a Binary Message, the OnBinary event is fired. Read the Data parameter to retrieve the binary message received.


private void OnBinary(TsgcWSConnection Connection, byte[] Bytes)
{
  MemoryStream stream = new MemoryStream(Bytes);
  pictureBox1.Image = new Bitmap(stream);
}

By default, client uses neAsynchronous method to dispatch OnMessage event, this means that this event is executed on the context of Main Thread, so it's thread-safe to update any control of a form for example.

 

If your client receives lots of messages or you need to control the synchronization with other threads, set NotifyEvents property to neNoSync, this means that OnMessage event will be executed on the context of connection thread, so if you require to update any control of a form or access shared objects, you must implement your own synchronization methods.