Class VirtualConnection
java.lang.Object
arc.net.Connection
com.xpdustry.claj.api.net.VirtualConnection
public class VirtualConnection
extends arc.net.Connection
A connection that doesn't have a socket and buffer behind.
Every writes is done to the proxy, and listeners are triggered by him.
And some internal
Every writes is done to the proxy, and listeners are triggered by him.
And some internal
Connection states are exposed for more control.
This must not be used like a standard Connection,
as some internal states like listeners cannot be fully overridden.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final com.xpdustry.claj.common.net.DispatchListenerprotected final intprotected Stringfinal ProxyClientThe real client, aka the proxy.protected final InetSocketAddressFake address calculated using the hash of the real client address provided by the server. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(arc.net.NetListener listener) Only used when sending world datavoidclose(arc.net.DcReason reason) voidcloseQuietly(arc.net.DcReason reason) Close the connection without notify the server about that.arc.net.EndPointintgetID()arc.net.ArcNetExceptionarc.net.NetListener[]intintbooleanbooleanisIdle()The server will notify if the client is idling.voidvoidnotifyDisconnected0(arc.net.DcReason reason) voidvoidnotifyReceived0(Object object) voidremoveListener(arc.net.NetListener listener) Only used when sending world datavoidintintvoidsetConnected0(boolean connected) voidsetIdleThreshold(float idleThreshold) voidsetKeepAliveTCP(int keepAliveMillis) voidvoidsetTimeout(int timeoutMillis) toString()voidvoidMethods inherited from class arc.net.Connection
getArbitraryData, setArbitraryData
-
Field Details
-
proxy
The real client, aka the proxy. -
id
protected final int id -
dispatcher
protected final com.xpdustry.claj.common.net.DispatchListener dispatcher -
remoteAddress
Fake address calculated using the hash of the real client address provided by the server.
TCP and UDP ports are always the same, so no need to have two InetSocketAddress. -
name
-
-
Constructor Details
-
VirtualConnection
-
-
Method Details
-
sendTCP
- Overrides:
sendTCPin classarc.net.Connection
-
sendUDP
- Overrides:
sendUDPin classarc.net.Connection
-
close
public void close(arc.net.DcReason reason) - Overrides:
closein classarc.net.Connection
-
closeQuietly
public void closeQuietly(arc.net.DcReason reason) Close the connection without notify the server about that.
Common use is when the server itself is saying to close the connection. -
getListeners
public arc.net.NetListener[] getListeners() -
addListener
public void addListener(arc.net.NetListener listener) Only used when sending world data- Overrides:
addListenerin classarc.net.Connection
-
removeListener
public void removeListener(arc.net.NetListener listener) Only used when sending world data- Overrides:
removeListenerin classarc.net.Connection
-
notifyConnected0
public void notifyConnected0() -
notifyDisconnected0
public void notifyDisconnected0(arc.net.DcReason reason) -
notifyIdle0
public void notifyIdle0() -
notifyReceived0
-
updateIdle
public void updateIdle() -
resetIdle
public void resetIdle() -
setConnected0
public void setConnected0(boolean connected) -
getID
public int getID()- Overrides:
getIDin classarc.net.Connection
-
isConnected
public boolean isConnected()- Overrides:
isConnectedin classarc.net.Connection
-
getLastProtocolError
public arc.net.ArcNetException getLastProtocolError()- Overrides:
getLastProtocolErrorin classarc.net.Connection
-
updateReturnTripTime
public void updateReturnTripTime()- Overrides:
updateReturnTripTimein classarc.net.Connection
-
getReturnTripTime
public int getReturnTripTime()- Overrides:
getReturnTripTimein classarc.net.Connection
-
setKeepAliveTCP
public void setKeepAliveTCP(int keepAliveMillis) - Overrides:
setKeepAliveTCPin classarc.net.Connection
-
setTimeout
public void setTimeout(int timeoutMillis) - Overrides:
setTimeoutin classarc.net.Connection
-
getEndPoint
public arc.net.EndPoint getEndPoint()- Overrides:
getEndPointin classarc.net.Connection
-
getRemoteAddressTCP
- Overrides:
getRemoteAddressTCPin classarc.net.Connection
-
getRemoteAddressUDP
- Overrides:
getRemoteAddressUDPin classarc.net.Connection
-
setName
- Overrides:
setNamein classarc.net.Connection
-
getTcpWriteBufferSize
public int getTcpWriteBufferSize()- Overrides:
getTcpWriteBufferSizein classarc.net.Connection
-
isIdle
public boolean isIdle()The server will notify if the client is idling.- Overrides:
isIdlein classarc.net.Connection
-
setIdleThreshold
public void setIdleThreshold(float idleThreshold) - Overrides:
setIdleThresholdin classarc.net.Connection
-
toString
- Overrides:
toStringin classarc.net.Connection
-