Class ClajProxyManager

java.lang.Object
com.xpdustry.claj.api.ClajProxyManager

public class ClajProxyManager extends Object
  • Field Details

    • workers

      protected final int workers
    • provider

      protected final ClajProvider provider
    • created

      protected int created
    • proxies

      protected final ClajProxy[] proxies
    • threads

      protected final Thread[] threads
    • reserved

      protected final boolean[] reserved
  • Constructor Details

    • ClajProxyManager

      public ClajProxyManager(ClajProvider provider)
    • ClajProxyManager

      public ClajProxyManager(ClajProvider provider, int workers)
  • Method Details

    • getProxyName

      public String getProxyName(int index)
    • hasCreatedProxies

      public boolean hasCreatedProxies()
    • createdProxies

      public int createdProxies()
    • proxies

      public int proxies()
    • provider

      public ClajProvider provider()
    • ensureCreated

      public ClajProxy ensureCreated(int index)
    • ensureStarted

      public ClajProxy ensureStarted(int index)
    • get

      public ClajProxy get()
      Returns:
      the first proxy.
    • get

      public ClajProxy get(int index)
    • getOrNull

      public ClajProxy getOrNull(int index)
    • findFree

      public ClajProxy findFree()
      Search for a proxy with no created room.
    • findFreeI

      public int findFreeI()
    • isBusy

      public boolean isBusy(int index)
    • isRoomCreated

      public boolean isRoomCreated()
      Checks the first proxy.
    • isRoomCreated

      public boolean isRoomCreated(int index)
    • isRoomClosed

      public boolean isRoomClosed()
      Checks the first proxy.
    • isRoomClosed

      public boolean isRoomClosed(int index)
    • hasOpenRoom

      public boolean hasOpenRoom()
      Search whether a proxy have an open room.
    • closeRoom

      public void closeRoom()
      Closes the first proxy's room.
    • closeRoom

      public void closeRoom(int index)
    • closeAllRooms

      public void closeAllRooms()
    • dispose

      public void dispose()
      Dispose all proxies.
    • stop

      public void stop()
      Close all rooms and stop all proxies.
    • createRoom

      public ClajProxy createRoom(String host, int port, arc.func.Cons<ClajLink> created, arc.func.Cons<com.xpdustry.claj.common.status.CloseReason> closed, arc.func.Cons<Throwable> failed)
      This will try to find an available proxy.
      Returns:
      the proxy on which the room was opened. (does not guarantee that the room is already open or will be.)
    • createRoom

      public ClajProxy createRoom(int index, String host, int port, arc.func.Cons<ClajLink> created, arc.func.Cons<com.xpdustry.claj.common.status.CloseReason> closed, arc.func.Cons<Throwable> failed)