Packet handler in Client is not called after reconnecting
till-f opened this issue · comments
The handler that is registered on the client connection is not called anymore when the connection is closed and then re-created from scratch.
This is my code to create the client connection (TcpConnection
):
private static TcpConnection Connect()
{
var clientConnection = ConnectionFactory.CreateTcpConnection("127.0.0.1", Port, out var connectionResult);
if (connectionResult == ConnectionResult.Connected)
{
clientConnection.RegisterStaticPacketHandler<MyResponsePacket>(OnPacketReceived);
clientConnection.ConnectionClosed += OnConnectionClosed;
return clientConnection;
}
Console.WriteLine("Could not connect.");
return null;
}
After first connection, the response sent by the server is properly received in the OnPacketReceived
method. But after closing the connection from the client using clientConnection.Close(CloseReason.ClientClosed)
, any new TcpConnection
created with the code above does not seem to receive anything. The packet handler is not called even though it is re-registered after construction.
I also tried to unregister the handler in the OnConnectionClosed
method, but this does not have an effect.
See here for a complete demo project to reproduce the issuse:
https://github.com/till-f/Examples/tree/main/Toemsel.Network