Info about thread

ok Problem is

while true do begin
lList := fThreads.LockList;
try

  if lList.Count = 0 then break;
finally
  fThreads.UnlockList;
end;
Sleep(integer(50));

end;
in ThreadPool destroy. It have infinite loop and never terminate Threads…

this code means that all items should be processed before thread pool can be destroyed.

if server fired something like server shutdown event when it should be closed, clients should perform disconnect. it may improve situation because they wouldn’t send requests to server

ok I ll do it but problem remain…

so it doesn t destroy thread in threadpool and loop is infinite

ok problem is not server …
problem is Client…
I Disconnect it from Server and close my app but also in this case doesn t close Threads…
So if I don t solve problem because component cause problem and after 2 days I don t have any solution please refund money because component dosn t works…

I’m reviewing your testcase. server can be closed correctly if client was closed before server and can’t if it was closed before client. I’ll investigate this case

it works for me with server shutdown event : test.zip (115.3 KB)

Problem is client and not server… Server close correctly but client hang

it works for me for both cases: server was closed and then client was closed and vice versa
have you tested updated testcase?

It seem that works… How Can i disconnect client from server with tguid?

you have no public access to internal list of connected clients, i.e. to TROBaseSuperTCPServer.fClients

Ok so how to disconnect a client? I remove session but doesn t works

In server can I disable EventClient ?

Can I use RegisterEventClient in Server?

in Alessandro’s testcase, no login/logoff is needed … so even you remove session, client can re-register it again …

you can use .NET-compatible version of events. this one is server based.
read the Event Sinks and Server Callbacks article for more details.

Ok Two questions…

  1. how Can i remove dialog ‘connection not avaiable’ It always display when connection is not avaiable’
  2. eventsink procedure in client run in main thread? Because when riceive many bytes in Short time It hang my application

Thanks

can you provide exactly exception message or callstack for this exception, pls?

it depends on TROEventReceiver.SynchronizeInvoke property:

Thank You…

Missing last step to finish my test i Need to Serialize/unserialize a com object. Explain me that It possibile to do with
CoMemoryStream.Create
CoBinaryFormatter.Create
binaryFormatter.Serialize
memoryStream.GetBuffer

I have Tried but i have many problems. Can You make a Simple example to Serialize/unserialize a com object in binary field?

Thanks

you can try to use

procedure ReadObjectFromSerializer(const ASerializer: TROSerializer; anObject : TObject);
procedure WriteObjectToSerializer(const ASerializer: TROSerializer; anObject: TObject);

from uROSerializer.pas, but I’m not sure that it will work properly with COM objects, but you can create a wrapper for each type that will serialize/deserialize them.

Ok There is a Delphi example how to use It?

it can be something like

uses
  uROTypes, uROJSONMessage, uROClientIntf, uROSerializer;

type
  {$M+}
  TMyType = class
  private
    fb: Integer;
    fa: String;
  published
    property a: String read fa write fa;
    property b: Integer read fb write fb;
  end;


procedure TForm79.Button1Click(Sender: TObject);
var
  t, t1: TMyType;
  js: TROJSONMessage;
  m: IROMessage;
  s: TMemoryStream;
begin
  t := TMyType.Create;
  t.a:='test';
  t.b := 100;

  // writing object
  js:= TROJSONMessage.Create(nil);
  try
    m :=(js as IROMessage);
    m.InitializeRequestMessage(nil,'','','');
    WriteObjectToSerializer(js.Serializer,t);
    m.Finalize;
    s := TMemoryStream.Create;
    try
      m.WriteToStream(s);
      Memo1.Lines.LoadFromStream(s);
    finally
      s.Free;
    end;
  finally
    m := nil;
    js.Free;
  end;

  //reading object
  t1 := TMyType.Create;
  js:= TROJSONMessage.Create(nil);
  try
    m :=(js as IROMessage);
    s := TMemoryStream.Create;
    try
      Memo1.Lines.SaveToStream(s);
      m.ReadFromStream(s);
    finally
      s.Free;
    end;
    m.InitializeRead(nil);
    ReadObjectFromSerializer(js.Serializer,t1);
    m.Finalize;
  finally
    m := nil;
    js.Free;
  end;

  if (t.a = t1.a) and (t.b = t1.b) then
    ShowMessage('OK')
  else
    ShowMessage('ERROR');

  t.Free;
  t1.Free;
end;

Ok Last Question…

I m using RoService…

1)How can I Insert Sevice Description?
2)I need service path because I need read some configuration files. How can I have service path?

Br,Alessandro