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

Autoconnect to Client everytime it opens #32

Open
KruemelopmentDev opened this issue Jan 7, 2023 · 1 comment
Open

Autoconnect to Client everytime it opens #32

KruemelopmentDev opened this issue Jan 7, 2023 · 1 comment

Comments

@KruemelopmentDev
Copy link

KruemelopmentDev commented Jan 7, 2023

Hey guys,
I created a jar and turned it into an exe, starting when my PC boots. This is my connection code:

Client api = new ClientApi();
api.addClientConnectionListener(new ClientConnectionListener() {
    @Override
     public void onClientConnected() {
         infoLog("Client connected");
         connectSocket();
      }

      @Override
       public void onClientDisconnected() {
            infoLog("Client disconnected");
            socket.close();
        }
});

This code is called when the program starts. It should get when the client is available and connect with the websocket, if it fails first time then it should retry 4 times to connect the socket with a delay of 30 seconds after each try. Sometimes it does work sometimes it does not, do anybody maybe knows why? Is it a problem with the exe or inside the code?

@stirante
Copy link
Owner

stirante commented Jan 9, 2023

In my app I also have such issue and in that case I reconnect every second. It works most of the times, but honestly I don't really know the exact reason why it might be. It happens so rarely, that it's hard to debug. Here is a piece of code for reference from RuneChanger, that uses this library
https://github.com/stirante/RuneChanger/blob/master/app/src/main/java/com/stirante/runechanger/RuneChanger.java#L411

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

2 participants