Discussion:
Track a list of connected clients and send them commands
(too old to reply)
Nacef LABIDI
2008-07-03 13:56:52 UTC
Permalink
Hi there,

I want to develop a simple client/server application. My server has to
handle multiple clients connection and I want it to keep a list of
connected clients. On the client side I want to be able to send a
command from a client to the server which will broadcast it to the other
connected clients. As far as I have read, I saw in the ScreenThief demo
that it is using a TThreadList in which the connected threads are
registered but as I am using Indy10 The ServerConnect event handler does
not provide a TidPeerThread as a parameter but a TidContext. So what's
the solution in this case. Also I have read that the server cannot
explicitly send a command to a client so how can I pass the received
command back to the other clients.

I am using this mechanism in my application to allow my different
clients to update their state each time that one of the client's state
changes.

Has anyone an idea on how to implement that ?

Thanks

Nacef
Remy Lebeau (TeamB)
2008-07-03 17:10:35 UTC
Permalink
My server has to handle multiple clients connection and I want
it to keep a list of connected clients.
TIdTCPServer already does all of that for you.
On the client side I want to be able to send a command from
a client to the server which will broadcast it to the other
connected clients.
Examples of doing that have been posted many times before. Please go to
http://www.deja.com and search the newsgroup archives.
As far as I have read, I saw in the ScreenThief demo that it is
using a TThreadList in which the connected threads are registered
That is redundant to do manually.
as I am using Indy10 The ServerConnect event handler does not
provide a TidPeerThread as a parameter but a TidContext.
They are essentially the same thing, except TIdContext is not derived from
TThread like TIdPeerThread is. But they represent the same thing - an
individual client connection. TIdTCPServer has a Threads property in Indy 9
and earlier, and a Contexts property in Indy 10, that contains a list of
connected clients.
Also I have read that the server cannot explicitly send a command to
a client
Yes, it can. Again, please search the newsgroup archives for examples. You
will also have to make sure that your communication protocol supports
unsolicited commands being sent by the server to a client. Examples of that
have been posted as well.


Gambit

Loading...