0

I'm working on an xna networked game with lidgren and I can get the client and server to connect, but whenever the client receives a message in the DiscoveryRequest case I get the IndexOutOfRangeException error.

Code for recieving messages in client:

while ((incMsg = client.ReadMessage()) != null)
        {
            switch (incMsg.MessageType)
            {
                case NetIncomingMessageType.Data:
                    Console.WriteLine("recieved message");
                    break;

                case NetIncomingMessageType.DiscoveryRequest:
                    Console.WriteLine("Connected",incMsg.ReadString());
                    client.Connect(incMsg.SenderEndpoint);
                    break;
                default:
                    Console.WriteLine("Unhandled type: " + incMsg.MessageType);
                    break;
            }
            client.Recycle(incMsg);
        }
BenMorel
  • 34,448
  • 50
  • 182
  • 322

1 Answers1

1

Way old question, but for posterity: the DiscoveryRequest does not contain any payload, there is no string to read. It's detailed here: https://code.google.com/p/lidgren-network-gen3/wiki/Discovery

lidgren
  • 463
  • 2
  • 9