Board index » delphi » INDY -Chat Room Demo

INDY -Chat Room Demo

There is a bug in the following procedure for the onDisconnect. My
experament is three client connections. As I close each connection (out
of order) on the last disconnected client I get "list index out of
bounds" @ Clients.Delete(Client.ListLink); and of cource the proper
connection is not removed from the listBox.

Has this been reported?

procedure TfrmMain.tcpServerDisconnect(AThread: TIdPeerThread);
var
  Client : TSimpleClient;
begin
{ Retrieve Client Record from Data pointer }
  Client := Pointer(AThread.Data);
{ Remove Client from the Clients TList }
  Clients.Delete(Client.ListLink);                //fails here with a
list index out of bounds
{ Remove Client from the Clients List Box }
  lbClients.Items.Delete(lbClients.Items.IndexOf(Client.Name));
  BroadcastMessage('System', Client.Name + ' has left the chat.');
{ Free the Client object }
  Client.Free;
  AThread.Data := nil;
end;

 

Re:INDY -Chat Room Demo


Change it to read

  Clients.Delete(lbClients.ItemIndex)

The problem with the code is that the Client.ListIndex is a fixed value
assigned when the user logs on, yet the index of the list changes (ie people
disconnect not in the order connected) and on the UpdateClientList
procedure.

Hope this helps.

Quote
"Fredrick Bartlett" <palmtree...@earthlink.net> wrote in message

news:3A4E1AD3.D83A16F0@earthlink.net...
Quote
> There is a bug in the following procedure for the onDisconnect. My
> experament is three client connections. As I close each connection (out
> of order) on the last disconnected client I get "list index out of
> bounds" @ Clients.Delete(Client.ListLink); and of cource the proper
> connection is not removed from the listBox.

> Has this been reported?

> procedure TfrmMain.tcpServerDisconnect(AThread: TIdPeerThread);
> var
>   Client : TSimpleClient;
> begin
> { Retrieve Client Record from Data pointer }
>   Client := Pointer(AThread.Data);
> { Remove Client from the Clients TList }
>   Clients.Delete(Client.ListLink);                file://fails here with a
> list index out of bounds
> { Remove Client from the Clients List Box }
>   lbClients.Items.Delete(lbClients.Items.IndexOf(Client.Name));
>   BroadcastMessage('System', Client.Name + ' has left the chat.');
> { Free the Client object }
>   Client.Free;
>   AThread.Data := nil;
> end;

Re:INDY -Chat Room Demo


Fredrick,

Have a look here there is a great example of client multithread list. You
can easily adopt to your liking. I cam across this when I had the same
problem you are having.

http://www.undu.com/Articles/980807b.html

Let me know how it works.

Ricardo Casillas
AndOnSoft

Quote
"Fredrick Bartlett" <palmtree...@earthlink.net> wrote in message

news:3A4E1AD3.D83A16F0@earthlink.net...
Quote
> There is a bug in the following procedure for the onDisconnect. My
> experament is three client connections. As I close each connection (out
> of order) on the last disconnected client I get "list index out of
> bounds" @ Clients.Delete(Client.ListLink); and of cource the proper
> connection is not removed from the listBox.

> Has this been reported?

> procedure TfrmMain.tcpServerDisconnect(AThread: TIdPeerThread);
> var
>   Client : TSimpleClient;
> begin
> { Retrieve Client Record from Data pointer }
>   Client := Pointer(AThread.Data);
> { Remove Client from the Clients TList }
>   Clients.Delete(Client.ListLink);                //fails here with a
> list index out of bounds
> { Remove Client from the Clients List Box }
>   lbClients.Items.Delete(lbClients.Items.IndexOf(Client.Name));
>   BroadcastMessage('System', Client.Name + ' has left the chat.');
> { Free the Client object }
>   Client.Free;
>   AThread.Data := nil;
> end;

Re:INDY -Chat Room Demo


"Fredrick Bartlett" <palmtree...@earthlink.net> schrieb im Newsbeitrag
news:3A4E1AD3.D83A16F0@earthlink.net...
Quote
> There is a bug in the following procedure for the onDisconnect. My
> experament is three client connections. As I close each connection (out
> of order) on the last disconnected client I get "list index out of
> bounds" @ Clients.Delete(Client.ListLink); and of cource the proper
> connection is not removed from the listBox.

> Has this been reported?

You can also have a look to my V50 project in HrunS.pas,
the user list is generated asyncronly.

Ernst Gerlach
ernst.gerl...@epost.de
http://www.gerlach-mtl.de <<<< here you find
--- use plain text only in email ---

Re:INDY -Chat Room Demo


Thank you all...
Is the INDY Chat Room Demo thread safe?   With simple fixes to the client
lists "Clients.Delete(Client.ListIndex)",  would the INDY demo hold up with
say 300 plus users?  Would the clients list handle users logging in and out
often?

Fredrick

Quote
Fredrick Bartlett wrote:
> There is a bug in the following procedure for the onDisconnect. My
> experament is three client connections. As I close each connection (out
> of order) on the last disconnected client I get "list index out of
> bounds" @ Clients.Delete(Client.ListLink); and of cource the proper
> connection is not removed from the listBox.

> Has this been reported?

> procedure TfrmMain.tcpServerDisconnect(AThread: TIdPeerThread);
> var
>   Client : TSimpleClient;
> begin
> { Retrieve Client Record from Data pointer }
>   Client := Pointer(AThread.Data);
> { Remove Client from the Clients TList }
>   Clients.Delete(Client.ListLink);                //fails here with a
> list index out of bounds
> { Remove Client from the Clients List Box }
>   lbClients.Items.Delete(lbClients.Items.IndexOf(Client.Name));
>   BroadcastMessage('System', Client.Name + ' has left the chat.');
> { Free the Client object }
>   Client.Free;
>   AThread.Data := nil;
> end;

Re:INDY -Chat Room Demo


Yes, well done...  Bit complicated though, expecially for English only
speakers.
Can you explain "DBBlock : TMultiReadExclusiveWriteSynchronizer;" Does this
block all threads from reading and/or writing to the client lists?

Fredrick

Quote
Ernst Gerlach wrote:
> "Fredrick Bartlett" <palmtree...@earthlink.net> schrieb im Newsbeitrag
> news:3A4E1AD3.D83A16F0@earthlink.net...
> > There is a bug in the following procedure for the onDisconnect. My
> > experament is three client connections. As I close each connection (out
> > of order) on the last disconnected client I get "list index out of
> > bounds" @ Clients.Delete(Client.ListLink); and of cource the proper
> > connection is not removed from the listBox.

> > Has this been reported?

> You can also have a look to my V50 project in HrunS.pas,
> the user list is generated asyncronly.

> Ernst Gerlach
> ernst.gerl...@epost.de
> http://www.gerlach-mtl.de <<<< here you find
> --- use plain text only in email ---

Re:INDY -Chat Room Demo


Quote
Fredrick Bartlett wrote:
> Is the INDY Chat Room Demo thread safe?   With simple fixes to the client
> lists "Clients.Delete(Client.ListIndex)",  would the INDY demo hold up with
> say 300 plus users?  Would the clients list handle users logging in and out
> often?

It has been the belief of us in the Indy team from the start that most
servers these days would tackle 300+ threads without a hitch. If this
assumption does not hold true, then please let us know.

Aside from the client list, the chat server demo itself should be fine
AFAIK. (I did notify the demo list over a month ago wrt these and
similar issues, but in all the pre-yule commotion no-one - including
myself - followed up on it)

--
Rune

Re:INDY -Chat Room Demo


<<would the INDY demo hold up with
say 300 plus users?  Would the clients list handle users logging in and out
often?

with the blocking sockets on the server does that mean that 300 threads must
run?

--
Steve Garland sgarl...@astatech.com
Code it once with ASTA and run it anywhere
Servers (Win32,Linux) Clients (Win32,Linux,Java,Palm,WinCE)
ASTA Technology Group http://www.astatech.com

Re:INDY -Chat Room Demo


Hmmmm... Steve Garland, where have I seen that name before!
I'm not very thread aware, multi threading is a weak point for me.  Looking at
the INDY Chat Room Demo,  it looks like a new thread is created for each
connection...
Quote
Steve Garland wrote:
> <<would the INDY demo hold up with
> say 300 plus users?  Would the clients list handle users logging in and out
> often?

> with the blocking sockets on the server does that mean that 300 threads must
> run?

> --
> Steve Garland sgarl...@astatech.com
> Code it once with ASTA and run it anywhere
> Servers (Win32,Linux) Clients (Win32,Linux,Java,Palm,WinCE)
> ASTA Technology Group http://www.astatech.com

Re:INDY -Chat Room Demo


"Fredrick Bartlett" <palmtree...@earthlink.net> schrieb im Newsbeitrag
news:3A4F5EDC.C44E943D@earthlink.net...
Quote
> Yes, well done...  Bit complicated though, expecially for English only
> speakers.

I know, but i have my problems with my bad english

Quote
> Can you explain "DBBlock : TMultiReadExclusiveWriteSynchronizer;" Does
this
> block all threads from reading and/or writing to the client lists?

Yes

I try a short translation:
wer ist online = who is online;
Text senden = sending text (normal chat operation);
Rufliste = a lsit of all registered users (you can call);
Pressmail = start mail exchange between V50 and internet;
Ist Post da? = are there mails for that user
(chat client shows count of mails for the user and count
of mails, waiting to be sended to internet)
(Rufen 0 = Alle) = call users / 0 = all users, >0 = call only one user
(position from callerlist);
Zeit senden = sending time (server is sycroni from internet);
Text an einzelne Person = send text to a sigle user;
AnmeldeProcedure = log in;
Rasanforderung = user can call ras for http proxy
(client sends every second as long user wants connection);
Serverprotokoll = user can see the log window from server;
Kopieeinstellung = set up mail copy (user can tell with chatclient to the
mailserver,
to make a copy of all emails to him, to make a copy to an other user.
NOT recursive);
Serverprotokoll l?schen = clear server log (only possible by the first user,
with is the postmaster);
Code anfordern = sending savety code <not used>
regards

Ernst Gerlach
ernst.gerl...@epost.de
http://www.gerlach-mtl.de
--- use plain text only in email ---

Re:INDY -Chat Room Demo


in ASTA 3 for Linux/Windows we now allow for any sockets to be used and Indy
is one we are using right now in tests.

the other question that I posted before about indy is how the client can
detect when a server goes down. seems like they can't unless they try to
actually send some data.

--
Steve Garland sgarl...@astatech.com
Code it once with ASTA and run it anywhere
Servers (Win32,Linux) Clients (Win32,Linux,Java,Palm,WinCE)
ASTA Technology Group http://www.astatech.com

Re:INDY -Chat Room Demo


Does anybody have any opinions on the use of
TMultiReadExclusiveWriteSynchronizer. What kind of performance issues should I
expect with hundreds of users connecting and disconnecting?  My company is
dumping Netware for NT and I have until April to reinvent NWPopup, which is a
critical tool in our business.  I have some unique needs and there are no off
the shelf solutions that could possably address them. I have done several
prototype using different socket tools and have determined that INDY will be
it.  Any and all suggestions will be appreciated.

Thanks,
Fredrick

Quote
Ernst Gerlach wrote:
> "Fredrick Bartlett" <palmtree...@earthlink.net> schrieb im Newsbeitrag
> news:3A4F5EDC.C44E943D@earthlink.net...
> > Yes, well done...  Bit complicated though, expecially for English only
> > speakers.
> I know, but i have my problems with my bad english

> > Can you explain "DBBlock : TMultiReadExclusiveWriteSynchronizer;" Does
> this
> > block all threads from reading and/or writing to the client lists?
> Yes

> I try a short translation:
> wer ist online = who is online;
> Text senden = sending text (normal chat operation);
> Rufliste = a lsit of all registered users (you can call);
> Pressmail = start mail exchange between V50 and internet;
> Ist Post da? = are there mails for that user
> (chat client shows count of mails for the user and count
> of mails, waiting to be sended to internet)
> (Rufen 0 = Alle) = call users / 0 = all users, >0 = call only one user
> (position from callerlist);
> Zeit senden = sending time (server is sycroni from internet);
> Text an einzelne Person = send text to a sigle user;
> AnmeldeProcedure = log in;
> Rasanforderung = user can call ras for http proxy
> (client sends every second as long user wants connection);
> Serverprotokoll = user can see the log window from server;
> Kopieeinstellung = set up mail copy (user can tell with chatclient to the
> mailserver,
> to make a copy of all emails to him, to make a copy to an other user.
> NOT recursive);
> Serverprotokoll l?schen = clear server log (only possible by the first user,
> with is the postmaster);
> Code anfordern = sending savety code <not used>
> regards

> Ernst Gerlach
> ernst.gerl...@epost.de
> http://www.gerlach-mtl.de
> --- use plain text only in email ---

Re:INDY -Chat Room Demo


<<It has been the belief of us in the Indy team from the start that most
servers these days would tackle 300+ threads without a hitch.

I would hope to see some kind of thread pooling also. I see the threadMgr
but from the help if I remember correctly it is only active when running
stateless protocols.

--
Steve Garland sgarl...@astatech.com
Code it once with ASTA and run it anywhere
Servers (Win32,Linux) Clients (Win32,Linux,Java,Palm,WinCE)
ASTA Technology Group http://www.astatech.com

Re:INDY -Chat Room Demo


Quote
Steve Garland wrote:
> in ASTA 3 for Linux/Windows we now allow for any sockets to be used and Indy
> is one we are using right now in tests.

> the other question that I posted before about indy is how the client can
> detect when a server goes down. seems like they can't unless they try to
> actually send some data.

That was on my list of questions.  Why is there not an onDisconnected event?
What is INDY's solution/suggestion for dectecting/handling this.
Quote

> --
> Steve Garland sgarl...@astatech.com
> Code it once with ASTA and run it anywhere
> Servers (Win32,Linux) Clients (Win32,Linux,Java,Palm,WinCE)
> ASTA Technology Group http://www.astatech.com

Re:INDY -Chat Room Demo


Hellooo,  TIdTCPClient does have a onDisconnect event!!!
Quote
Steve Garland wrote:
> in ASTA 3 for Linux/Windows we now allow for any sockets to be used and Indy
> is one we are using right now in tests.

> the other question that I posted before about indy is how the client can
> detect when a server goes down. seems like they can't unless they try to
> actually send some data.

> --
> Steve Garland sgarl...@astatech.com
> Code it once with ASTA and run it anywhere
> Servers (Win32,Linux) Clients (Win32,Linux,Java,Palm,WinCE)
> ASTA Technology Group http://www.astatech.com

Go to page: [1] [2]

Other Threads