Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packet handler in Client is not called after reconnecting #93

Open
till-f opened this issue Jan 6, 2023 · 0 comments
Open

Packet handler in Client is not called after reconnecting #93

till-f opened this issue Jan 6, 2023 · 0 comments

Comments

@till-f
Copy link

till-f commented Jan 6, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant