marceldev89 / BattleNET

BattlEye Protocol Library and Client
GNU Lesser General Public License v3.0
76 stars 44 forks source link

Calling the BattlEyeClient.Disconnect() function raises the OnDisconnect() event twice #11

Closed Wotuu closed 11 years ago

Wotuu commented 11 years ago

The issue lies in the fact that the function itself raises the OnDisconnect() event, and the event is raised when the main loop dies as well (DoWork() function).

Simple solution would be to remove the OnDisconnect() event from the BattlEyeClient.Disconnect() function, and let the DoWork() function handle the event.

marceldev89 commented 11 years ago

Hmm maybe I should start using versions to track issues. ^^

Did you try it with the latest code? It shouldn't happen anymore though. When you call Disconnect() it sets _keepRunning to false which is then checked. It should only fire once.

if (!_socket.Connected)
{
    if (_reconnectOnPacketLoss && _keepRunning)
    {
        Connect();
    }
    else if (!_keepRunning)
    {
        //let the thread finish without further action
    }
    else
    {
        OnDisconnect(_loginCredentials, _disconnectionType);
    }
}
Wotuu commented 11 years ago

No I didn't update the code because I'm afraid it'll break stuff and I can't be arsed to fix it :p. Hence the "Not sure if this is still around in the current version" comment in my original post.

But I guess I should update and fix the errors that may pop up. I have another issue that Ill post about when I see it isn't fixed / added in the latest version.

marceldev89 commented 11 years ago

I've (hopefully) made sure to keep possible breaking to a minimum. All you have to do to get it working again is changing

IBattleNET b = new BattlEyeClient(loginCredentials);

to

BattlEyeClient b = new BattlEyeClient(loginCredentials);
Wotuu commented 11 years ago

Too much effort!

J/k, sweet, I'll update it later today when I get home from work then!

marceldev89 commented 11 years ago

Might have found the cause, have you set ReconnectOnPacketLoss to false?

Wotuu commented 11 years ago

I already told you what the cause was and how to solve it? :o

ReConnectOnPacketLoss is true. I have already manually fixed the issue by what was stated above.

marceldev89 commented 11 years ago

Oh my bad, sorry. I was talking about the latest code. Your specific bug shouldn't happen in latest code anyway. I guess I was talking about a different case.

Still waiting for confirmation though. :)

Wotuu commented 11 years ago

I didn't get around to updating the lib yet (was too busy with writing my own code; read: I forgot). I will report back if I updated it and it happens still!

Edit: I did get around to creating some nice stuff up till now, so I can't thank you enough for the lib!

marceldev89 commented 11 years ago

I'm assuming this is fixed?

Wotuu commented 11 years ago

Yes sorry, it is fixed!

marceldev89 commented 11 years ago

Awesome. :)