Marc,
Why we are jumping to the another planet now?
We are soo close!!
Can you please see the code!
This is just getting complicated all the time.
Isn't this component having anything such as: CLIENTID?, CLIENTNO?, ID?
which could be posted here in the same way as the IP address and the Port?
Come on guys,
This can't be this complicated!
too many opinions but none simple??
Here is what I have,
---------------------------------------------------------------------------------------
procedure TSimpleSslServerForm.SslWSocketServer1ClientConnect(
Sender : TObject;
Client : TWSocketClient;
Error : Word);
begin
with Client as TTcpSrvClient do begin
Display('Client connected.' +
'[' + THEID or the CLIENTNUMBER or ANYTHING which helps to
identify + ']' + ///Here I need to get this info into the
brackets....
' Remote: ' + PeerAddr + '/' + PeerPort +
' Local: ' + GetXAddr + '/' + GetXPort);
Display('There is now ' +
IntToStr(TWSocketServer(Sender).ClientCount) +
' clients connected.');
LineMode := True;
LineEdit := True;
LineLimit := 80; { Do not accept long lines }
OnDataAvailable := ClientDataAvailable;
OnLineLimitExceeded := ClientLineLimitExceeded;
OnBgException := ClientBgException;
OnSslVerifyPeer := ClientVerifyPeer;
ConnectTime := Now;
end;
end;
Actually, TWSocketServer(Sender).ClientCount-1 will be your client
number, until one of the client disconnect.
Since it's a dynamic array, when a client disconnect, the client
number will change.
That`s why you need another way to identify your clients.
From memory, when my client connected, they would send the server
their unique ID and I would store that into a property of the client
socket. You have to derive your client socket and add properties to
it.
Something like :
TTcpSrvClient = class(TWSocketClient)
public
ConnectTime : TDateTime;
UniqueID : string;
end;
then you assign that client socket in the server initialization (in
the TcpSrv demo,in WMAppStartup) :
WSocketServer1.ClientClass := TTcpSrvClient; { Use our component }
Then when I wanted to send a command to a particular client, I would
just iterate all connected client searching for the right ID.
hth
--
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
--
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