So there is an issue when a client connects and disconnects from the server and then: reconnecting with the same Client instance sometimes does not work; you get timed out after a few seconds. To reproduce this, you can use the ConsoleServer demo and I have rewritten the ConsoleClient to connect and disconnect when enter is pressed. Use this code for the client:
using Riptide.Utils;
using System;
using System.Threading;
namespace Riptide.Demos.ConsoleClient
{
internal class Program
{
private static Client client;
private static bool isRunning;
private static void Main()
{
client = new Client();
client.Connected += (s, e) => Console.WriteLine("Press enter to disconnect at any time.");
client.Disconnected += (s, e) => Console.WriteLine("Press enter to connect at any time.");
RiptideLogger.Initialize(Console.WriteLine, true);
new Thread(new ThreadStart(Loop)).Start();
while (true)
{
Console.ReadLine();
isRunning = !isRunning;
if (isRunning)
client.Connect("127.0.0.1:7777");
else
client.Disconnect();
}
}
private static void Loop()
{
while (true)
{
if (isRunning)
{
client.Update();
}
Thread.Sleep(10);
}
}
}
}
Try reconnecting and wait a few seconds to see if you get timed out; if not, just disconnect and connect again. As I said, reconnecting sometimes works, so you need to try more reconnects, but I feel like the chance to not get disconnected is 50/50 or smaller.
First client connection is always stable. Until this issue is fixed, just make a new instance of Client before connecting to the server.
So there is an issue when a client connects and disconnects from the server and then: reconnecting with the same Client instance sometimes does not work; you get timed out after a few seconds. To reproduce this, you can use the ConsoleServer demo and I have rewritten the ConsoleClient to connect and disconnect when enter is pressed. Use this code for the client: