> Here is what I have, > and please see the line for the client number, > Now I at least now where should I define it, just need to find out how? > --------------------------------------------------------------------------------------- > procedure TSimpleSslServerForm.SslWSocketServer1ClientConnect( > Sender : TObject; > Client : TWSocketClient; > Error : Word); > begin > with Client as TTcpSrvClient do begin > Display('Client connected.' + > '[]' + ///Here I need to get the client number 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