public class Client extends java.lang.Object implements SelectHandler
Constructor and Description |
---|
Client(java.lang.String host,
int port,
Config cfg,
Progress looper,
ChannelHandler handler) |
Client(java.lang.String host,
int port,
Config cfg,
Progress looper,
ChannelHandler handler,
boolean fixBuffers) |
Modifier and Type | Method and Description |
---|---|
boolean |
connect() |
void |
disconnect() |
void |
disconnectGraceFully(long waitTime)
Stop the client while trying to process any queued requests and responses
|
void |
handleAccept(java.nio.channels.SelectableChannel ch)
Handle accept availability of channel
|
void |
handleConnect(java.nio.channels.SelectableChannel selectableChannel)
Handle a connection ready for channel
|
void |
handleError(java.nio.channels.SelectableChannel ch)
Handle error of channel
|
void |
handleRead(java.nio.channels.SelectableChannel ch)
Handle read availability of channel
|
void |
handleWrite(java.nio.channels.SelectableChannel ch)
Handle write availability of channel
|
boolean |
isConnected() |
TCPMessage |
receive(java.nio.channels.SocketChannel sc,
java.nio.ByteBuffer buffer,
int size,
int edge) |
TCPMessage |
send(java.nio.channels.SocketChannel sc,
java.nio.ByteBuffer buffer,
int size,
int edge) |
void |
setHostAndPort(java.lang.String host,
int port)
this method must be called when the client is disconnected
|
void |
tryConnecting()
this method may be called when the target machine may not be up yet
this method may be called repeatedly, until it connects
connection exceptions are ignored, they are not propagated to connection handler
connection attempt fails silently
|
public Client(java.lang.String host, int port, Config cfg, Progress looper, ChannelHandler handler)
public Client(java.lang.String host, int port, Config cfg, Progress looper, ChannelHandler handler, boolean fixBuffers)
public void setHostAndPort(java.lang.String host, int port)
public boolean connect()
public void tryConnecting()
public boolean isConnected()
public TCPMessage send(java.nio.channels.SocketChannel sc, java.nio.ByteBuffer buffer, int size, int edge)
public TCPMessage receive(java.nio.channels.SocketChannel sc, java.nio.ByteBuffer buffer, int size, int edge)
public void disconnect()
public void disconnectGraceFully(long waitTime)
public void handleRead(java.nio.channels.SelectableChannel ch)
SelectHandler
handleRead
in interface SelectHandler
ch
- socket channelpublic void handleWrite(java.nio.channels.SelectableChannel ch)
SelectHandler
handleWrite
in interface SelectHandler
ch
- socket channelpublic void handleAccept(java.nio.channels.SelectableChannel ch)
SelectHandler
handleAccept
in interface SelectHandler
ch
- socket channelpublic void handleConnect(java.nio.channels.SelectableChannel selectableChannel)
SelectHandler
handleConnect
in interface SelectHandler
selectableChannel
- socket channelpublic void handleError(java.nio.channels.SelectableChannel ch)
SelectHandler
handleError
in interface SelectHandler
ch
- socket channel