|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.sf.xenqtt.message.MqttMessage
net.sf.xenqtt.message.ConnectMessage
public final class ConnectMessage
The MQTT connect message. When a TCP/IP socket connection is established from a client to a server, a protocol level session must be created using a CONNECT flow.
Constructor Summary | |
---|---|
ConnectMessage(ByteBuffer buffer,
int remainingLength,
long receivedTimestamp)
Create a new instance of this class. |
|
ConnectMessage(String clientId,
boolean cleanSession,
int keepAliveSeconds)
Create an instance with no credentials and no will message. |
|
ConnectMessage(String clientId,
boolean cleanSession,
int keepAliveSeconds,
String userName,
String password)
Create an instance with credentials and no will message. |
|
ConnectMessage(String clientId,
boolean cleanSession,
int keepAliveSeconds,
String willTopic,
String willMessage,
QoS willQos,
boolean willRetain)
Create an instance with no credentials and a will message. |
|
ConnectMessage(String clientId,
boolean cleanSession,
int keepAliveSeconds,
String userName,
String password,
String willTopic,
String willMessage,
QoS willQos,
boolean willRetain)
Create an instance with credentials and a will message. |
Method Summary | |
---|---|
String |
getClientId()
The Client Identifier (Client ID) is between 1 and 23 characters long, and uniquely identifies the client to the server. |
int |
getKeepAliveSeconds()
The Keep Alive timer, measured in seconds, defines the maximum time interval between messages received from a client. |
String |
getPassword()
If the Password flag is set, this is the next UTF-encoded string. |
String |
getProtocolName()
String that represents the protocol name MQIsdp, capitalized as shown. |
int |
getProtocolVersion()
The revision level of the protocol used by the client. |
String |
getUserName()
The user name identifies the name of the user who is connecting, which can be used for authentication. |
String |
getWillMessage()
The Will Message defines the content of the message that is published to the Will Topic if the client is unexpectedly disconnected. |
QoS |
getWillQoS()
|
int |
getWillQoSLevel()
|
String |
getWillTopic()
The Will Message is published to the Will Topic. |
boolean |
isCleanSession()
If not set, then the server must store the subscriptions of the client after it disconnects. |
boolean |
isPasswordFlag()
|
boolean |
isUserNameFlag()
|
boolean |
isWillMessageFlag()
|
boolean |
isWillRetain()
The retain value of the Will message. |
Methods inherited from class net.sf.xenqtt.message.MqttMessage |
---|
byteBufferToHex, bytesToHex, equals, getMessageType, getQoS, getQoSLevel, getReceivedTimestamp, getRemainingLength, isAck, isAckable, isDuplicate, isRetain, setDuplicateFlag, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ConnectMessage(ByteBuffer buffer, int remainingLength, long receivedTimestamp)
buffer
- The buffer that contains the contents of the messageremainingLength
- The remaining length of the messagereceivedTimestamp
- The time at which the message was receivedpublic ConnectMessage(String clientId, boolean cleanSession, int keepAliveSeconds)
public ConnectMessage(String clientId, boolean cleanSession, int keepAliveSeconds, String userName, String password)
public ConnectMessage(String clientId, boolean cleanSession, int keepAliveSeconds, String willTopic, String willMessage, QoS willQos, boolean willRetain)
public ConnectMessage(String clientId, boolean cleanSession, int keepAliveSeconds, String userName, String password, String willTopic, String willMessage, QoS willQos, boolean willRetain)
Method Detail |
---|
public String getProtocolName()
public int getProtocolVersion()
public boolean isCleanSession()
If set, then the server must discard any previously maintained information about the client and treat the connection as "clean". The server must also discard any state when the client disconnects.
Typically, a client will operate in one mode or the other and not change. The choice will depend on the application. A clean session client will not receive stale information and it must resubscribe each time it connects. A non-clean session client will not miss any QoS 1 or QoS 2 messages that were published whilst it was disconnected. QoS 0 messages are never stored, since they are delivered on a best efforts basis.
This flag was formerly known as "Clean start". It has been renamed to clarify the fact it applies to the whole session and not just to the initial connect.
A server may provide an administrative mechanism for clearing stored information about a client which can be used when it is known that a client will never reconnect.
public String getClientId()
public String getWillTopic()
getWillQoS()
and the RETAIN status is defined by
isWillRetain()
.
Null if there is no Will Message.
public boolean isWillMessageFlag()
public String getWillMessage()
Although the Will Message is UTF-8 encoded in the CONNECT message, when it is published to the Will Topic only the bytes of the message are sent, not the first two length bytes. The message must therefore only consist of 7-bit ASCII characters.
Null if there is no Will Message. Zero length string if there is an empty Will Message.
public QoS getWillQoS()
willMessage
. If there is not a Will Message then this is not applicable.public int getWillQoSLevel()
willMessage
. If there is not a Will Message then this is not applicable.public boolean isWillRetain()
public boolean isUserNameFlag()
public String getUserName()
Note that, for compatibility with the original MQTT V3 specification, the Remaining Length field from the fixed header takes precedence over the User Name flag. Server implementations must allow for the possibility that the User Name flag is set, but the User Name string is missing. This is valid, and connections should be allowed to continue.
Null if there is no user name.
public boolean isPasswordFlag()
public String getPassword()
Note that, for compatibility with the original MQTT V3 specification, the Remaining Length field from the fixed header takes precedence over the Password flag. Server implementations must allow for the possibility that the Password flag is set, but the Password string is missing. This is valid, and connections should be allowed to continue.
Null if there is no password. If there is no username there can be no password.
public int getKeepAliveSeconds()
If the server does not receive a message from the client within one and a half times the Keep Alive time period (the client is allowed "grace" of half a time period), it disconnects the client as if the client had sent a DISCONNECT message. This action does not impact any of the client's subscriptions. See DISCONNECT for more details.
If a client does not receive a PINGRESP message within a Keep Alive time period after sending a PINGREQ, it should close the TCP/IP socket connection.
The Keep Alive timer is a 16-bit value that represents the number of seconds for the time period. The actual value is application-specific, but a typical value is a few minutes. The maximum value is approximately 18 hours. A value of zero (0) means the client is not disconnected.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |