|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.xenqtt.message.MqttBrokerChannel
public final class MqttBrokerChannel
An MqttChannel
to use for the client side of the connection.
Constructor Summary | |
---|---|
MqttBrokerChannel(SocketChannel channel,
MessageHandler handler,
Selector selector,
long messageResendIntervalMillis)
|
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()
|
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 MqttBrokerChannel(SocketChannel channel, MessageHandler handler, Selector selector, long messageResendIntervalMillis) throws IOException
messageResendIntervalMillis
- Millis between attempts to resend a message that MqttMessage.isAckable()
. 0 to disable message resends
IOException
Method Detail |
---|
public final void deregister()
MqttChannel
SelectionKey
.
deregister
in interface MqttChannel
MqttChannel.deregister()
public final boolean register(Selector selector, MessageHandler handler)
MqttChannel
SelectionKey
for the previously registered selector, if any, is canceled. The current
MessageHandler
is replaced with the specified one.
register
in interface MqttChannel
MqttChannel.register(java.nio.channels.Selector, net.sf.xenqtt.message.MessageHandler)
public final boolean finishConnect()
MqttChannel
SelectionKey
s SelectionKey.OP_CONNECT
op is ready.
finishConnect
in interface MqttChannel
MqttChannel.finishConnect()
public final boolean read(long now)
MqttChannel
MessageHandler
.This should be called when a SelectionKey
s
SelectionKey.OP_READ
op is ready.
read
in interface MqttChannel
now
- The timestamp to use as the "current" time
MqttChannel.read(long)
public boolean send(MqttMessage message, BlockingCommand<MqttMessage> blockingCommand)
MqttChannel
DisconnectMessage
or a ConnAckMessage
where ConnAckMessage.getReturnCode()
is
not ConnectReturnCode.ACCEPTED
is sent the channel is closed automatically.
send
in interface MqttChannel
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.MqttChannel.send(net.sf.xenqtt.message.MqttMessage, net.sf.xenqtt.message.BlockingCommand)
public final boolean write(long now)
MqttChannel
SelectionKey
s SelectionKey.OP_WRITE
op is ready.
write
in interface MqttChannel
now
- The timestamp to use as the "current" time
MqttChannel.write(long)
public final void close()
MqttChannel
close
in interface MqttChannel
MqttChannel.close()
public final void close(Throwable cause)
MqttChannel
MessageHandler.channelClosed(MqttChannel, Throwable)
callback.
close
in interface MqttChannel
MqttChannel.close(java.lang.Throwable)
public final boolean isOpen()
MqttChannel
isOpen
in interface MqttChannel
MqttChannel.isOpen()
public final boolean isConnected()
MqttChannel
MqttChannel.isOpen()
is true, Connect/ConnectAck has finished, and no
disconnect has been received/sent.
isConnected
in interface MqttChannel
MqttChannel.isConnected()
public final boolean isConnectionPending()
MqttChannel
isConnectionPending
in interface MqttChannel
MqttChannel.finishConnect()
methodMqttChannel.isConnectionPending()
public final long houseKeeping(long now)
MqttChannel
houseKeeping
in interface MqttChannel
now
- 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 MqttChannel
MqttChannel.sendQueueDepth()
public final int inFlightMessageCount()
inFlightMessageCount
in interface MqttChannel
MqttChannel.inFlightMessageCount()
public void cancelBlockingCommands()
MqttChannel
Cancels
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 MqttChannel
MqttChannel.cancelBlockingCommands()
public List<MqttMessage> getUnsentMessages()
getUnsentMessages
in interface MqttChannel
MqttChannel.getUnsentMessages()
public String getRemoteAddress()
getRemoteAddress
in interface MqttChannel
MqttChannel.getRemoteAddress()
public String toString()
toString
in class Object
Object.toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |