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.
Code:
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