lidgren / lidgren-network-gen3

Lidgren Network Library
https://groups.google.com/forum/#!forum/lidgren-network-gen3
MIT License
1.19k stars 331 forks source link

Disconnect don't get recognized by lidgren #42

Closed Skyppid closed 9 years ago

Skyppid commented 9 years ago

EDIT: I'm very very sorry for the inconvenience. It was my fault, I messed up some task continuations which resulted in never calling shutdown. I should have known better. You might delete this issue. Sorry.

Hello,

I'm using lidgren for some sort of remote controlling (not visually, just values). So far it's implemented like I used to implement it in all projects. It works perfectly fine so far, connecting does work properly.

The thing is: When I call NetPeer.Shutdown() or NetClient.Disconnect() on either the server or client, nothing happens. The opposite won't get informed about any status changes.

Could it be that the application gets terminated before the NetPeer internally is able to send the last messages? How could I possibly wait for them to finish? The shutdown gets called on application exit (WinForm or WPF). I can't haphazardly wait a second or so. This would slow down application exits which is a total no-go.

I am using the newest version (pulled on 12.09.2015). Here's my client / server configuration: Server

            _config = new NetPeerConfiguration(SetupConsts.NET_APP_ID)
            {
                Port = SetupConsts.NET_DEFAULT_PORT
            };
            _config.EnableMessageType(NetIncomingMessageType.DiscoveryRequest);
            _config.EnableMessageType(NetIncomingMessageType.StatusChanged);
            _server = new NetServer(_config);

Client

            _config = new NetPeerConfiguration(SetupConsts.NET_APP_ID);
            _config.EnableMessageType(NetIncomingMessageType.DiscoveryResponse);
            _client = new NetClient(_config);

I'm willing to give more source code if required (via E-Mail).

And as little offtopic question: I tried it in local network from Laptop to my dev PC. Hosting the server on the laptop works, my application connects from the dev PC to it. But it doesn't find the server if I do it vice-versa. How comes?