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
The claj client that redirects packets from the relay to the local mindustry server.
-
Field Summary
FieldsModifier and TypeFieldDescriptionbooleanstatic final intId meaning that that the connection is invalid, and used to broadcast packets to all clients.booleanbooleanprotected ClajLinkfinal ClajProviderbooleanCan be used to not callroomClosedcallback, if the error is already handled.protected arc.func.Cons<com.xpdustry.claj.common.status.CloseReason> protected arc.func.Cons<ClajLink> protected longshortstatic final longConstant value saying that no room is created.Fields inherited from class ProxyClient
broadcastSupported, closing, conListener, connectHost, connecting, connections, connectionsMap, connectTcpPort, connectTimeout, connectUdpPort, defaultTimeout, errorHandler, forceTcp, lastPing, pingTime, receiver, shutdown, starting, writeBufferThreshold -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidcloseRoom(com.xpdustry.claj.common.status.CloseReason reason) nullreason means closed by user.protected VirtualConnectionconConnected(int conId, long addressHash) protected VirtualConnectionconDisconnected(int conId, arc.net.DcReason reason) protected VirtualConnectionconIdle(int conId) voidconnect(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 method must be used instead of others connect methodsprotected VirtualConnectionconReceived(int conId, Object object) link()protected com.xpdustry.claj.common.packets.PacketmakeBroadcastClosePacket(arc.net.DcReason reason) protected com.xpdustry.claj.common.packets.PacketmakeBroadcastWrapPacket(Object object, boolean tcp) protected com.xpdustry.claj.common.packets.PacketmakeConClosePacket(int conId, arc.net.DcReason reason) protected com.xpdustry.claj.common.packets.PacketmakeConWrapPacket(int conId, Object object, boolean tcp) protected com.xpdustry.claj.common.packets.Packetprotected com.xpdustry.claj.common.packets.PacketmakeRoomConfigPacket(boolean isPublic, boolean isProtected, short password, boolean requestState) protected com.xpdustry.claj.common.packets.PacketmakeRoomCreatePacket(int version, com.xpdustry.claj.common.status.ClajType type) protected com.xpdustry.claj.common.packets.PacketmakeRoomStatePacket(long roomId, ByteBuffer state) voidvoidprotected <T> voidpostTask(arc.func.Cons<T> consumer, T object) protected <T1,T2> void postTask(arc.func.Cons2<T1, T2> consumer, T1 t1, T2 t2) protected voidvoidbooleanlongroomId()0means no room created.protected voidrunRoomClose(com.xpdustry.claj.common.status.CloseReason reason) This also resets room id and removes callbacks.protected voidrunRoomCreated(long roomId) voidsetDefaultConfiguration(boolean isPublic, boolean isProtected, short roomPassword, boolean allowStateRequests) Methods inherited from class ProxyClient
addConnection, broadcast, broadcastImpl, clearConnections, close, close, close, closeAllConnections, closeQuietly, connect, connect, eachConnections, getConnection, getConnections, getConnectionsSize, hasConnection, isConnecting, isRunning, removeConnection, run, send, send, send, sendTCP, start, stop, update, updateIdle, updatePingMethods inherited from class arc.net.Client
close, connect, connect, connect, discoverHosts, dispose, getSerialization, getUpdateThread, handleNetException, reconnect, reconnect, setDiscoveryPacket, setKeepAliveUDPMethods inherited from class arc.net.Connection
addListener, getArbitraryData, getEndPoint, getID, getLastProtocolError, getRemoteAddressTCP, getRemoteAddressUDP, getReturnTripTime, getTcpWriteBufferSize, isConnected, isIdle, removeListener, sendTCPBuffer, sendUDP, sendUDPBuffer, setArbitraryData, setIdleThreshold, setKeepAliveTCP, setName, setTimeout, toString, updateReturnTripTimeMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface arc.net.EndPoint
addListener, removeListener
-
Field Details
-
UNCREATED_ROOM
public static final long UNCREATED_ROOMConstant value saying that no room is created. This should be handled as an invalid id.- See Also:
-
CON_BROADCAST
public static final int CON_BROADCASTId 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
-
isPublic
public boolean isPublic -
isProtected
public boolean isProtected -
allowStateRequests
public boolean allowStateRequests -
roomPassword
public short roomPassword -
quietErrors
public boolean quietErrorsCan be used to not callroomClosedcallback, if the error is already handled. -
roomCreated
-
roomClosed
protected arc.func.Cons<com.xpdustry.claj.common.status.CloseReason> roomClosed -
roomId
protected long roomId -
link
-
-
Constructor Details
-
ClajProxy
-
-
Method Details
-
connect
-
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
-
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()0means no room created. -
roomCreated
public boolean roomCreated() -
link
-
closeRoom
public void closeRoom() -
closeRoom
public void closeRoom(com.xpdustry.claj.common.status.CloseReason reason) nullreason 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() -
conConnected
- Overrides:
conConnectedin classProxyClient- Returns:
nullif room isn't created or ifconIdisCON_BROADCAST.
-
conDisconnected
- Overrides:
conDisconnectedin classProxyClient- Returns:
nullif room isn't created or ifconIdisCON_BROADCAST.
-
conReceived
- Overrides:
conReceivedin classProxyClient- Returns:
nullif room isn't created or ifconIdisCON_BROADCAST.
-
conIdle
- Overrides:
conIdlein classProxyClient- Returns:
nullif room isn't created or ifconIdisCON_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:
makeBroadcastWrapPacketin classProxyClient
-
makeBroadcastClosePacket
protected com.xpdustry.claj.common.packets.Packet makeBroadcastClosePacket(arc.net.DcReason reason) - Specified by:
makeBroadcastClosePacketin classProxyClient
-
makeConWrapPacket
protected com.xpdustry.claj.common.packets.Packet makeConWrapPacket(int conId, Object object, boolean tcp) - Specified by:
makeConWrapPacketin classProxyClient
-
makeConClosePacket
protected com.xpdustry.claj.common.packets.Packet makeConClosePacket(int conId, arc.net.DcReason reason) - Specified by:
makeConClosePacketin classProxyClient
-