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);
}