|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.xenqtt.message.MqttClientChannel
public final class MqttClientChannel
An MqttChannel to use for the client side of the connection.
| Constructor Summary | |
|---|---|
MqttClientChannel(String host,
int port,
MessageHandler handler,
Selector selector,
long messageResendIntervalMillis,
BlockingCommand<?> connectionCompleteCommand,
net.sf.xenqtt.message.MutableMessageStats stats)
Starts an asynchronous connection to the specified host and port. |
|
| Method Summary | |
|---|---|
void |
cancelBlockingCommands()
Cancels all blocking commands. |
void |
close()
Closes the underlying channels, sockets, etc |
void |
close(Throwable cause)
Closes the underlying channels, sockets, etc and sends cause to the MessageHandler.channelClosed(MqttChannel, Throwable) callback. |
void |
deregister()
Deregisters this channel. |
boolean |
finishConnect()
Finishes a connection. |
String |
getLocalAddress()
|
String |
getRemoteAddress()
|
List<MqttMessage> |
getUnsentMessages()
|
long |
houseKeeping(long now)
Performs housekeeping: message resends, ping requests, etc |
int |
inFlightMessageCount()
|
boolean |
isConnected()
Tells whether or not this channel is connected. |
boolean |
isConnectionPending()
Tells whether or not a connection operation is in progress on this channel. |
boolean |
isOpen()
Tells whether or not this channel is open. |
void |
pauseRead()
Pauses reading on the channel. |
boolean |
read(long now)
Reads data. |
boolean |
register(Selector selector,
MessageHandler handler)
Registers this channel with the specified selector. |
void |
resumeRead()
Resumes reading on this channel. |
boolean |
send(MqttMessage message)
Sends the specified message asynchronously. |
boolean |
send(MqttMessage message,
BlockingCommand<MqttMessage> blockingCommand)
Sends the specified message asynchronously. |
int |
sendQueueDepth()
|
String |
toString()
|
boolean |
write(long now)
Writes as much data as possible. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public MqttClientChannel(String host,
int port,
MessageHandler handler,
Selector selector,
long messageResendIntervalMillis,
BlockingCommand<?> connectionCompleteCommand,
net.sf.xenqtt.message.MutableMessageStats stats)
throws IOException
SelectionKey for the specified selector has
SelectionKey.OP_CONNECT as a ready op then finishConnect() should be called.
messageResendIntervalMillis - Millis between attempts to resend a message that MqttMessage.isAckable(). 0 to disable message resendsconnectionCompleteCommand - If not null then this latch is complete when the ConnAckMessage is received.
IOException| Method Detail |
|---|
public final void deregister()
MqttChannelSelectionKey.
deregister in interface MqttChannelMqttChannel.deregister()
public final boolean register(Selector selector,
MessageHandler handler)
MqttChannelMessageHandler
is replaced with the specified one.
register in interface MqttChannelMqttChannel.register(java.nio.channels.Selector, net.sf.xenqtt.message.MessageHandler)public final boolean finishConnect()
MqttChannelSelectionKeys SelectionKey.OP_CONNECT op is ready.
finishConnect in interface MqttChannelMqttChannel.finishConnect()public final boolean read(long now)
MqttChannelMessageHandler.This should be called when a SelectionKeys
SelectionKey.OP_READ op is ready.
read in interface MqttChannelnow - The timestamp to use as the "current" time
MqttChannel.read(long)public void pauseRead()
MqttChannelMqttChannel.resumeRead().
pauseRead in interface MqttChannelMqttChannel.pauseRead()public void resumeRead()
MqttChannel
resumeRead in interface MqttChannelMqttChannel.resumeRead()public final boolean send(MqttMessage message)
MqttChannelDisconnectMessage or a ConnAckMessage where ConnAckMessage.getReturnCode() is
not ConnectReturnCode.ACCEPTED is sent the channel is closed automatically.
This is the same as calling #send(MqttMessage, BlockingCommand, long) with a null BlockingCommand and 0 timestamp.
send in interface MqttChannelmessage - The message to send
MqttChannel.send(net.sf.xenqtt.message.MqttMessage)
public final boolean send(MqttMessage message,
BlockingCommand<MqttMessage> blockingCommand)
MqttChannelDisconnectMessage or a ConnAckMessage where ConnAckMessage.getReturnCode() is
not ConnectReturnCode.ACCEPTED is sent the channel is closed automatically.
send in interface MqttChannelmessage - The message to sendblockingCommand - If not null then this latch is complete when processing the message is complete. The definition of
complete is:
ConnectMessage processing is complete when the ConnAckMessage is received.ackable processing is complete when the ack is received.MqttChannel.send(net.sf.xenqtt.message.MqttMessage, net.sf.xenqtt.message.BlockingCommand)public final boolean write(long now)
MqttChannelSelectionKeys SelectionKey.OP_WRITE op is ready.
write in interface MqttChannelnow - The timestamp to use as the "current" time
MqttChannel.write(long)public final void close()
MqttChannel
close in interface MqttChannelMqttChannel.close()public final void close(Throwable cause)
MqttChannelMessageHandler.channelClosed(MqttChannel, Throwable) callback.
close in interface MqttChannelMqttChannel.close(java.lang.Throwable)public final boolean isOpen()
MqttChannel
isOpen in interface MqttChannelMqttChannel.isOpen()public final boolean isConnected()
MqttChannelMqttChannel.isOpen() is true, Connect/ConnectAck has finished, and no
disconnect has been received/sent.
isConnected in interface MqttChannelMqttChannel.isConnected()public final boolean isConnectionPending()
MqttChannel
isConnectionPending in interface MqttChannelMqttChannel.finishConnect()
methodMqttChannel.isConnectionPending()public final long houseKeeping(long now)
MqttChannel
houseKeeping in interface MqttChannelnow - The timestamp to use as the "current" time
MqttChannel.read(long) or MqttChannel.write(long) may change this value. Returns < 0 if this method closes the channel.MqttChannel.houseKeeping(long)public final int sendQueueDepth()
sendQueueDepth in interface MqttChannelMqttChannel.sendQueueDepth()public final int inFlightMessageCount()
inFlightMessageCount in interface MqttChannelMqttChannel.inFlightMessageCount()public final void cancelBlockingCommands()
MqttChannelCancels all blocking commands. This is not done when the channel is closed because we may want to reconnect instead of
releasing the commands.
cancelBlockingCommands in interface MqttChannelMqttChannel.cancelBlockingCommands()public final List<MqttMessage> getUnsentMessages()
getUnsentMessages in interface MqttChannelMqttChannel.getUnsentMessages()public final String getRemoteAddress()
getRemoteAddress in interface MqttChannelMqttChannel.getRemoteAddress()public String getLocalAddress()
getLocalAddress in interface MqttChannelMqttChannel.getLocalAddress()public final String toString()
toString in class ObjectObject.toString()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||