Reputation: 91
i am trying to write a telnet type program to read data from indy tcpserver
I want the user to first authenticate .. which is easy .. but the problem is where do I keep this authentication result so when the client executes another command, my tcpserver would know that this is an authenticated user and return data accordingly.
I hope I was specific.. and sorry for my English i'm from Venezuela.
Upvotes: 1
Views: 488
Reputation: 597540
TIdPeerThread
in Indy 9, and TIdContext
in Indy 10, both have a Data
property that you can store whatever you want in it.
A better option is to derive a new class from TIdPeerThread
/TIdServerContext
instead, add your custom fields/properties to that class as needed, and then assign that class to the server's ThreadClass
/ContextClass
property. Each command handler can then type-cast the provided APeerThread
/AContext
object to your class type to access your custom data.
You should look at the source code for Indy's own components that support user authentication, such as TIdPOP3Server
and TIdSMTPServer
, to see how they persist authentication data between commands.
Upvotes: 2