0

I want to create a server/client game in XNA 4.0 using lidgren where the client can list available servers/hosts and choose which server to join.

How can i use DiscoverLocalPeers or Client.DiscoverLocalPeers(40012); function to return a list of servers discovered. I am assuming the function looks for available server using the same port but i would like to list available servers using the port incase there more than one server. Is it possible or is my understanding of the function wrong.

Your help would be greatly appreciated

Mantsali
  • 1
  • 1

1 Answers1

1

I am not an expert with this library but DiscoverLocalPeers has a return type of void so I guess that this function only sends a message to servers with type DiscoveryRequest. So on your server side you should have something like this in order to handle incoming data :

 switch (incommingMessage.MessageType)
{
                    case NetIncomingMessageType.DebugMessage:
                    case NetIncomingMessageType.ErrorMessage:
                    case NetIncomingMessageType.WarningMessage:
                    case NetIncomingMessageType.VerboseDebugMessage:
                    case NetIncomingMessageType.StatusChanged:
                    case NetIncomingMessageType.DiscoveryRequest :
                            // here, you should send a response back with type DiscoveryResponse

                    default:
}
user26830
  • 1,059
  • 4
  • 16
  • 25
  • didnt really help.is there a way of identifying different server that use the same NetPeerConfiguration identifier – Mantsali May 18 '14 at 10:29