|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.esotericsoftware.kryonet.Connection
public class Connection
Represents a TCP and optionally a UDP connection between a Client
and a Server
. If either underlying connection
is closed or errors, both connections are closed.
Method Summary | |
---|---|
void |
addListener(Listener listener)
If the listener already exists, it is not added again. |
void |
close()
|
EndPoint |
getEndPoint()
Returns the local Client or Server to which this connection belongs. |
int |
getID()
Returns the server assigned ID. |
java.net.InetSocketAddress |
getRemoteAddressTCP()
Returns the IP address and port of the remote end of the TCP connection, or null if this connection is not connected. |
java.net.InetSocketAddress |
getRemoteAddressUDP()
Returns the IP address and port of the remote end of the UDP connection, or null if this connection is not connected. |
int |
getReturnTripTime()
Returns the last calculated TCP return trip time, or -1 if updateReturnTripTime() has never been called or the
FrameworkMessage.Ping response has not yet been received. |
boolean |
isConnected()
Returns true if this connection is connected to the remote end. |
void |
removeListener(Listener listener)
|
int |
sendTCP(java.lang.Object object)
Sends the object over the network using TCP. |
int |
sendUDP(java.lang.Object object)
Sends the object over the network using UDP. |
void |
setBufferPositionFix(boolean bufferPositionFix)
Workaround for broken NIO networking on Android 1.6. |
void |
setKeepAliveTCP(int keepAliveMillis)
An empty object will be sent if the TCP connection has not sent an object within the specified milliseconds. |
void |
setName(java.lang.String name)
Sets the friendly name of this connection. |
void |
setTimeout(int timeoutMillis)
If the specified amount of time passes without receiving an object over TCP, the connection is considered closed. |
java.lang.String |
toString()
|
void |
updateReturnTripTime()
Requests the connection to communicate with the remote computer to determine a new value for the return trip time . |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail |
---|
public int getID()
public boolean isConnected()
public int sendTCP(java.lang.Object object)
Kryo.register(Class, com.esotericsoftware.kryo.Serializer)
public int sendUDP(java.lang.Object object)
java.lang.IllegalStateException
- if this connection was not opened with both TCP and UDP.Kryo.register(Class, com.esotericsoftware.kryo.Serializer)
public void close()
public void updateReturnTripTime()
return trip time
. When the connection receives a FrameworkMessage.Ping
object with
isReply
set to true, the new return trip time is available.
public int getReturnTripTime()
updateReturnTripTime()
has never been called or the
FrameworkMessage.Ping
response has not yet been received.
public void setKeepAliveTCP(int keepAliveMillis)
setTimeout(int)
). Also, some network hardware will close a TCP connection that ceases to transmit for a period of time (typically 1+
minutes). Set to zero to disable. Defaults to 8000.
public void setTimeout(int timeoutMillis)
TCP keep alive
for the remote end of the connection. The keep alive ensures that the
remote end of the connection will be constantly sending objects, and setting the timeout higher than the keep alive allows
for network latency. Set to zero to disable. Defaults to 12000.
public void addListener(Listener listener)
public void removeListener(Listener listener)
public EndPoint getEndPoint()
Client
or Server
to which this connection belongs.
public java.net.InetSocketAddress getRemoteAddressTCP()
public java.net.InetSocketAddress getRemoteAddressUDP()
public void setBufferPositionFix(boolean bufferPositionFix)
public void setName(java.lang.String name)
toString()
and is useful for providing application
specific identifying information in the logging. May be null for the default name of "Connection X", where X is the
connection ID.
public java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |