Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted

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?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...