public class NioClient extends java.lang.Object implements MessageWriteTarget
StreamConnection
to process data.Constructor and Description |
---|
NioClient(java.net.SocketAddress serverAddress,
StreamConnection parser,
int connectTimeoutMillis)
Creates a new client to the given server address using the given
StreamConnection to decode the data. |
Modifier and Type | Method and Description |
---|---|
void |
closeConnection()
Closes the connection to the server, triggering the
StreamConnection.connectionClosed()
event on the network-handling thread where all callbacks occur. |
void |
writeBytes(byte[] message)
Writes the given bytes to the remote server.
|
public NioClient(java.net.SocketAddress serverAddress, StreamConnection parser, int connectTimeoutMillis) throws java.io.IOException
Creates a new client to the given server address using the given StreamConnection
to decode the data.
The given connection MUST be unique to this object. This does not block while waiting for the connection to
open, but will call either the StreamConnection.connectionOpened()
or
StreamConnection.connectionClosed()
callback on the created network event processing thread.
connectTimeoutMillis
- The connect timeout set on the connection (in milliseconds). 0 is interpreted as no
timeout.java.io.IOException
public void closeConnection()
MessageWriteTarget
StreamConnection.connectionClosed()
event on the network-handling thread where all callbacks occur.closeConnection
in interface MessageWriteTarget
public void writeBytes(byte[] message) throws java.io.IOException
MessageWriteTarget
writeBytes
in interface MessageWriteTarget
java.io.IOException