marceldev89 / BattleNET

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

Player list #22

Closed DeanHyde closed 11 years ago

DeanHyde commented 11 years ago

I'm issuing the 'players' command to then parse the returned player list. The issue is that when doing so, there seems to be a 50/50 chance of the session being disconnected with the error "Disconnected! (Socket Exception)".

marceldev89 commented 11 years ago

Got a code sample of what you're doing?

Try putting a sleep between connecting and sending the command.

DeanHyde commented 11 years ago

I don't have a code sample right now as I'm at work. I will post some when I get home.

Though I've tried multiple different approaches at getting the player list to load with 100% efficiency. My latest method was to have a manual 'refresh' button that would issue the 'players' command for me to then parse. Again, this has like a 50/50 chance of disconnecting. It doesn't seem to matter how long after connecting I send the 'players' command.

I had previously tried sending the 'players' command in place of the empty keep alive command, again with no luck.

Like I said, I'll send some sample code when I get home.

marceldev89 commented 11 years ago

I'm guessing that you fixed it yourself?

DeanHyde commented 11 years ago

No, I haven't managed to fix it. I've been trying to figure out exactly where the issue is arising. I have a feeling though it could be to do with how BE sends its playerlist. I've noticed while using BERcon.exe (battleyes own client) that sometimes when issuing the players command that they will send a player list back which is a bit malformed. The client doesn't disconnect though, which seems to happen when using IBattleNET library.

Anyway, for my client, I make the connection like so:

        private void tryConnect()
        {

            // if we're not connected yet
            if (isConnected == false)
            {
                BattlEyeLoginCredentials logcred = new BattlEyeLoginCredentials { Host = ip, Password = password, Port = Convert.ToInt32(port) };
                b = new BattlEyeClient(logcred);

                rtbDisplay.AppendText("\n Connecting...\n");

                // make the connection
                b.MessageReceivedEvent += DumpMessage;
                b.DisconnectEvent += Disconnected;
                b.Connect();

                if (b.IsConnected() == true)
                {
                    isConnected = true;
                    mnuConnect.Enabled = false;
                }
            }
        }

I then have a label that listens for a click that issues the 'players' command:


        private void lblRefresh_Click(object sender, EventArgs e)
        {
            b.SendCommandPacket("players");
        }

Finally, I listen for the player list every time a message is recieved:

        private void DumpMessage(BattlEyeMessageEventArgs args)
        {
            doDumpMessage(args.Message);
        }

        private void doDumpMessage(String msg)
        {
            if (msg.Substring(0, 10) == "Players on")
            {
                getPlayerList(msg);
            }
        }

getPlayerList() simply parses the returned player list and adds each player to a listbox. Like I said, it seems to work perfectly. But then randomly it'll make the client disconnect. And it would also seem that if it does it once, it's likely to crash for the couple of tries.

Hope this helps, I've just woke up so let me know if you need any more info.

marceldev89 commented 11 years ago

It disconnects with a socket exception, right?

If so, you must be firing it yourself because the library itself doesn't disconnect with a socket exception as far as I can see.

DeanHyde commented 11 years ago

Yeah. It's an immediate disconnect, there's no lag between me attempting to retrieve the player list and being disconnected with this:

 Disconnected! (Socket Exception)

 Disconnected! (Socket Exception)
marceldev89 commented 11 years ago

Are you running an older version of the library? As far as I can tell the library currently doesn't fire the socket exception disconnect type.

DeanHyde commented 11 years ago

Hmm, perhaps. I'll download the latest now and report back.

DeanHyde commented 11 years ago

So it would now seem that instead of disconnecting, my whole application freezes and doesn't recover.

marceldev89 commented 11 years ago

alright that's odd. Download this and try with the RCon client in there.

DeanHyde commented 11 years ago

Got a 404 on the link.

marceldev89 commented 11 years ago

Hmm just moved the domain to another place, it's probably not fully done yet. Try https://dl.dropbox.com/u/38551057/battlenet-bin-v1.2.1.zip

DeanHyde commented 11 years ago

That seems to work fine. I wouldn't bother continuing to scratch your head until I can absolutely make sure that it's a problem with the library. I don't want you wasting your time looking for an issue that may not even be there. I'll come back with more details when I have them.

I appreciate the help though :)