Neil Bullock wrote: > I'm new to using Indy, and I'm trying to make a simple TCP/IP server > program which allows a client program to log in using a > username/password, and then sends relevant pieces of information to > certain connected clients (depending on username). This information > sent back to clients could be at any time, so client connections need > to be maintained. > > I'm having trouble getting my head around keeping track of the various > Indy threads and what usernames those threads logged in with. Does > anyone know of any material online that covers this sort of thing?
You're using Indy 10, right? TIdTCPServer using a TIdContext object to keep track of connection-specific information. You can write your own descendant of that class to store other information, such as the ID of who's logged in. Set the server object's ContextClass property at run time, and whenever the server gets a new connection, it will create a new instance of your context class. The context object gets passed in during the server's OnExecute event, so you can read data from the connection and store log-in information in the context object. When your OnExecute event is ready to send its response, the context object will still have the same log-in information you gave it before. For that matter, the OnExecute handler's local variables will still have their same values, too, so you might not even need the context object. It might be more useful for passing information between the various server events, such as OnConnect, OnExecute, and OnDisconnect. -- Rob ----------------------------------------------------- Home page: http://groups.yahoo.com/group/delphi-en/ To unsubscribe: [EMAIL PROTECTED] Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/delphi-en/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/

