Client/Server messages

Roxbury

New member
Joined
Jul 4, 2006
Messages
3
Im using the Client/Server example from 101 vb samples 2003 and Im 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 doesnt 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
 
I cant see quite everything that youre doing but it looks like the "UserConnection" class will hold the remote users 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?
 
Back
Top