Roxbury Posted July 5, 2006 Posted July 5, 2006 I'm using the Client/Server example from 101 vb samples 2003 and I'm wondering how would I be able to have the users send messages to eachother individually? Currently you only talk in a public chat, however, for them to talk to individual people I think I need to connect to their ip, however, the server side doesn't seem to put the clients ip in the hashtable it creates. Can anyone please tell me how to go about recording the clients ip in the hashtable? The following is my server side code for it to listen for connections and put them into the hashtable, hopefully that helps. Private clients As New Hashtable Private listener As TcpListener Private listenerThread As Threading.Thread Private Sub DoListen() Try listener = New TcpListener(System.Net.IPAddress.Any, PORT_NUM) listener.Start() Do Dim client As New UserConnection(listener.AcceptTcpClient) AddHandler client.LineReceived, AddressOf OnLineReceived UpdateStatus("New connection found: waiting for log-in") Loop Until False Catch End Try End Sub Private Sub ConnectUser(ByVal userName As String, ByVal sender As UserConnection) sender.Name = userName UpdateStatus(userName & " has joined the chat.") clients.Add(userName, sender) ListUsers(sender) SendToClients("CHAT|" & sender.Name & " has joined the chat.", sender) End Sub Quote
Gill Bates Posted July 5, 2006 Posted July 5, 2006 I can't see quite everything that you're doing but it looks like the "UserConnection" class will hold the remote user's end point information. Are you planning to route all messages through the server or to spawn of a new connection for the peer-to-peer chat session? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.