Jump to content

ResponseCode usage


Recommended Posts

Posted
35 minutes ago, Lemons said:

So your mistake is thinking ResponseCode.isDisabledError knows the response code. It does not, it only checks the given response code (and your always giving 4 and 18, so its always true on any response code). Simple misunderstanding, those have bit all of us in the ass at some point.

 

That makes perfect sense. Thanks again for your help.

Posted (edited)

With lemon's help I found a way to make it work without a custom login handler, at least well enough to suit my needs here is what I did:

Spoiler

@Override
    public
     void onResponseCode(int responseCode)
            throws InterruptedException {
        if (ResponseCode.isDisabledError(responseCode)) {
        
            log("Account locked");
            try {
                log("trying to create text file.");
                PrintWriter writer = new PrintWriter(
                        
                        "/root/OSBot/Data/lockedAccounts.txt",
                        "UTF-8");
                writer.println("FIGJAM");
                writer.close();
            } catch (IOException e) {
                log("creating text file failed");
                // TODO Auto-generated catch block
                e.printStackTrace();
                System.exit(0);

            }
            System.exit(0);
        }if (ResponseCode.isConnectionError(responseCode)){
            log("login failed");
            try {
                log("trying to create text file.");
                PrintWriter writer = new PrintWriter(
                        
                        "/root/OSBot/Data/failedLogin.txt",
                        "UTF-8");
                writer.println("FIGJAM");
                writer.close();
            } catch (IOException e) {
                log("creating text file failed");
                // TODO Auto-generated catch block
                e.printStackTrace();
                System.exit(0);
        }
            
    }
}
}

What this does is write one file if the error type is disable error but a different file if it is a connection error (although I don't really need to write the second file).

 

Before it was executing my code on any error because I was passing thorough something that would always match. With this code it checks to see what kind of code it is, if it isn't a disabled code, it doesn't execute my instructions in the first section (which include an exit) and moves to the second. Since the second doesn't include an exit, the default login handler handles it like a normal connection error and waits 17 seconds to try again. Hopefully someone else can find use out of this.

 

Thanks Alek and lemons!

Edited by sudoinit6

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...