Class ClajProxy

java.lang.Object
arc.net.Connection
arc.net.Client
com.xpdustry.claj.api.net.ProxyClient
com.xpdustry.claj.api.ClajProxy
All Implemented Interfaces:
arc.net.EndPoint, Runnable

public class ClajProxy extends ProxyClient
The claj client that redirects packets from the relay to the local mindustry server.
  • Field Details

    • UNCREATED_ROOM

      public static final long UNCREATED_ROOM
      Constant value saying that no room is created. This should be handled as an invalid id.
      See Also:
    • CON_BROADCAST

      public static final int CON_BROADCAST
      Id meaning that that the connection is invalid, and used to broadcast packets to all clients.
      This is used for disconnect, received and idle events, but not for connected one, as it makes no sense.
      See Also:
    • provider

      public final ClajProvider provider
    • isPublic

      public boolean isPublic
    • isProtected

      public boolean isProtected
    • allowStateRequests

      public boolean allowStateRequests
    • roomPassword

      public short roomPassword
    • quietErrors

      public boolean quietErrors
      Can be used to not call roomClosed callback, if the error is already handled.
    • roomCreated

      protected arc.func.Cons<ClajLink> roomCreated
    • roomClosed

      protected arc.func.Cons<com.xpdustry.claj.common.status.CloseReason> roomClosed
    • roomId

      protected long roomId
  • Constructor Details

  • Method Details

    • createRoom

      public void 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)
    • postTask

      protected <T1,T2> void postTask(arc.func.Cons2<T1,T2> consumer, T1 t1, T2 t2)
    • postTask

      protected <T> void postTask(arc.func.Cons<T> consumer, T object)
    • postTask

      protected void postTask(Runnable run)
    • runRoomCreated

      protected void runRoomCreated(long roomId)
    • runRoomClose

      protected void runRoomClose(com.xpdustry.claj.common.status.CloseReason reason)
      This also resets room id and removes callbacks.
    • roomId

      public long roomId()
      0 means no room created.
    • roomCreated

      public boolean roomCreated()
    • link

      public ClajLink link()
    • closeRoom

      public void closeRoom()
    • closeRoom

      public void closeRoom(com.xpdustry.claj.common.status.CloseReason reason)
      null reason means closed by user.
    • requestRoomId

      public void requestRoomId()
    • setDefaultConfiguration

      public void setDefaultConfiguration(boolean isPublic, boolean isProtected, short roomPassword, boolean allowStateRequests)
    • notifyConfiguration

      public void notifyConfiguration()
    • notifyRoomState

      public void notifyRoomState()
    • isBroadcast

      protected boolean isBroadcast(int conId)
    • conConnected

      protected VirtualConnection conConnected(int conId, long addressHash)
      Overrides:
      conConnected in class ProxyClient
      Returns:
      null if room isn't created or if conId is CON_BROADCAST.
    • conDisconnected

      protected VirtualConnection conDisconnected(int conId, arc.net.DcReason reason)
      Overrides:
      conDisconnected in class ProxyClient
      Returns:
      null if room isn't created or if conId is CON_BROADCAST.
    • conReceived

      protected VirtualConnection conReceived(int conId, Object object)
      Overrides:
      conReceived in class ProxyClient
      Returns:
      null if room isn't created or if conId is CON_BROADCAST.
    • conIdle

      protected VirtualConnection conIdle(int conId)
      Overrides:
      conIdle in class ProxyClient
      Returns:
      null if room isn't created or if conId is CON_BROADCAST.
    • makeRoomStatePacket

      protected com.xpdustry.claj.common.packets.Packet makeRoomStatePacket(long roomId, ByteBuffer state)
    • makeRoomConfigPacket

      protected com.xpdustry.claj.common.packets.Packet makeRoomConfigPacket(boolean isPublic, boolean isProtected, short password, boolean requestState)
    • makeRoomCreatePacket

      protected com.xpdustry.claj.common.packets.Packet makeRoomCreatePacket(int version, com.xpdustry.claj.common.status.ClajType type)
    • makeRoomClosePacket

      protected com.xpdustry.claj.common.packets.Packet makeRoomClosePacket()
    • makeBroadcastWrapPacket

      protected com.xpdustry.claj.common.packets.Packet makeBroadcastWrapPacket(Object object, boolean tcp)
      Specified by:
      makeBroadcastWrapPacket in class ProxyClient
    • makeBroadcastClosePacket

      protected com.xpdustry.claj.common.packets.Packet makeBroadcastClosePacket(arc.net.DcReason reason)
      Specified by:
      makeBroadcastClosePacket in class ProxyClient
    • makeConWrapPacket

      protected com.xpdustry.claj.common.packets.Packet makeConWrapPacket(int conId, Object object, boolean tcp)
      Specified by:
      makeConWrapPacket in class ProxyClient
    • makeConClosePacket

      protected com.xpdustry.claj.common.packets.Packet makeConClosePacket(int conId, arc.net.DcReason reason)
      Specified by:
      makeConClosePacket in class ProxyClient