|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface MqttChannel
Sends and receives MqttMessage
s over a channel. This may be client or server side. Since read(long)
may generate data to send it should
always be called before write(long)
. houseKeeping(long)
should be called after both read(long)
and write(long)
as those
methods may change paramaters used to determine what housekeeping is required.
If any exception occurs the channel is closed.
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 |
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. |
boolean |
read(long now)
Reads data. |
boolean |
register(Selector selector,
MessageHandler handler)
Registers this channel with the specified selector. |
boolean |
send(MqttMessage message,
BlockingCommand<MqttMessage> blockingCommand)
Sends the specified message asynchronously. |
int |
sendQueueDepth()
|
boolean |
write(long now)
Writes as much data as possible. |
Method Detail |
---|
void deregister()
SelectionKey
.
boolean register(Selector selector, MessageHandler handler)
SelectionKey
for the previously registered selector, if any, is canceled. The current
MessageHandler
is replaced with the specified one.
boolean finishConnect()
SelectionKey
s SelectionKey.OP_CONNECT
op is ready.
boolean read(long now)
MessageHandler
.This should be called when a SelectionKey
s
SelectionKey.OP_READ
op is ready.
now
- The timestamp to use as the "current" time
boolean send(MqttMessage message, BlockingCommand<MqttMessage> blockingCommand)
DisconnectMessage
or a ConnAckMessage
where ConnAckMessage.getReturnCode()
is
not ConnectReturnCode.ACCEPTED
is sent the channel is closed automatically.
message
- 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.boolean write(long now)
SelectionKey
s SelectionKey.OP_WRITE
op is ready.
now
- The timestamp to use as the "current" time
void close()
void close(Throwable cause)
MessageHandler.channelClosed(MqttChannel, Throwable)
callback.
boolean isOpen()
boolean isConnected()
isOpen()
is true, Connect/ConnectAck has finished, and no
disconnect has been received/sent.
boolean isConnectionPending()
finishConnect()
methodlong houseKeeping(long now)
now
- The timestamp to use as the "current" time
read(long)
or write(long)
may change this value. Returns < 0 if this method closes the channel.int sendQueueDepth()
int inFlightMessageCount()
void cancelBlockingCommands()
Cancels
all blocking commands. This is not done when the channel is closed because we may want to reconnect instead of
releasing the commands.
List<MqttMessage> getUnsentMessages()
String getRemoteAddress()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |