When client receives a Binary Message, OnBinary event is fired, just read Data parameter to know the binary message received.
procedure OnBinary(Connection: TsgcWSConnection; const Data: TMemoryStream);
var
oBitmap: TBitmap;
begin
oBitmap := TBitmap.Create;
Try
oBitmap.LoadFromStream(Data);
Image1.Picture.Assign(oBitmap);
Log(
'#image uncompressed size: ' + IntToStr(Data.Size) +
'. Total received: ' + IntToStr(Connection.RecBytes));
Finally
FreeAndNil(oBitmap);
End;
end;
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.