stirante / lol-client-java-api

Simple library which provides access to internal League of Legends Client API.
GNU General Public License v3.0
67 stars 14 forks source link

Autoconnect to Client everytime it opens #32

Open KruemelopmentDev opened 1 year ago

KruemelopmentDev commented 1 year ago

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 commented 1 year ago

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