Re: [twsocket] how to send/recive Client list using twsocket client & server ?

2016-03-25 Thread Angus Robertson - Magenta Systems Ltd
> sl.text will send last inserted record to tstringlist it will not 
> send each client connected

I'm not interested in the logic behind your program, only the aspects
relating to using ICS. 

sl.text returns every item in the TStringList separated with CRLF, not
the last record, check the Delphi help. 

The point was there is no need to use a stream here, unless you have
several million items in the list. 

Angus


-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] how to send/recive Client list using twsocket client & server ?

2016-03-25 Thread matrin loanel
sl.text will send last inserted record to tstringlist it will not send each
client connected

On 19 March 2016 at 00:12, matrin loanel  wrote:

> i give up i searched a lot on how to send memory stream with Command to
> client i just wanted to send client list from server to client here is the
> code that i working on i dont really know what to do to send that
> clientcount that i collected from server and how to handle it to the client
> .
>
> //code//
>
> procedure TMyClient.SendClientsList;
> var
> I, J: Integer;
> SL: TStringList;
> MS: TMemoryStream;
> Client : TMyclient;
> Server : TWSocketServer;
> begin
> Server := mainserver.server;
>  try
>   SL := TStringList.Create;
> // Collect List
> for J := 0 to Server.ClientCount - 1 do
> begin
>   Client := TMyclient(Server.Client[J]);
>   SL.Add(Client.Name + Sep + IntToStr(Client.UniqueID) + Sep +
> Client.CURROOM + Sep + Client.icon);
> end;
>
> // Send List
> for I := 0 to Server.ClientCount- 1 do
> begin
>   Client := TMyclient(Server.Client[J]);
>   if (SL.Count > 0) then
>   begin
> MS := TMemoryStream.Create;
> try
>   SL.SaveToStream(MS);
>   MS.Position := 0;
>   //what to do to send ?
> finally
>   MS.Free;
> end;
>   end;
> end;
>   finally
>   SL.Free;
>   end;
>
> //end//
>
>
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] how to send/recive Client list using twsocket client & server ?

2016-03-19 Thread Angus Robertson - Magenta Systems Ltd
> i give up i searched a lot on how to send memory stream with 
> Command to client i just wanted to send client list from server
> to client

>   Client := TMyclient(Server.Client[J]);
>   if (SL.Count > 0) then
>   begin
> MS := TMemoryStream.Create;
> try
>   SL.SaveToStream(MS);

You don't really need to send a memory stream, since you data is
already in a TStringList.  So just use:

  Client.SendStr (SL.Text);

To send a stream, you read part of it into a buffer, and then send that
buffer.  It gets more complicated if the stream is vary large, since
the above version requires ICS to create buffers for all the data
passed, and you would not want to get a 2GByte buffer.  

Angus

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be