Class CMMqttManager
The protocol of the CMMqttManager class conforms to MQTT version 3.1.1. (http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/mqtt-v3.1.1.html)
CM wraps all MQTT messages in CM events so that CM nodes can run as a publisher or a subscriber.
-
Field Summary
Fields inherited from class kr.ac.konkuk.ccslab.cm.manager.CMServiceManager
m_cmInfo
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
connect()
Connects to the default server for the CM publish-subscribe service.boolean
connect
(String strWillTopic, String strWillMessage, boolean bWillRetain, byte willQoS, boolean bWillFlag, boolean bCleanSession) Connects to the default server for the CM publish-subscribe service.boolean
Disconnects the publish-subscribe service.Returns all retain information.Returns the string that contains session information of all CM clients.Returns the string that contains session information of a CM client.getSessionInfo
(String strUserName) Returns the string that contains session information of a CM client.static boolean
isTopicMatch
(String strTopic, String strFilter) boolean
Publishes a message.boolean
Publishes a message.boolean
Publishes a message.boolean
publishFromServerToOneClient
(String strTopic, String strMsg, byte qos, boolean bDupFlag, boolean bRetainFlag, String strClient, CMMqttSession session) boolean
boolean
resendSentUnAckPublish
(String strReceiver, CMMqttSession session) boolean
resendSentUnAckPubrel
(String strReceiver, CMMqttSession session) boolean
sendAndClearPendingTransPublish
(String strReceiver, CMMqttSession session) boolean
sendMqttWill
(String strUser) boolean
Subscribes a topic filter.boolean
subscribe
(CMList<CMMqttTopicQoS> topicQoSList) Subscribes a list of topic filters.boolean
unsubscribe
(String strTopic) Unsubscribes a topic filter.boolean
unsubscribe
(CMList<String> topicList) Unsubscribes a list of topic filters.Methods inherited from class kr.ac.konkuk.ccslab.cm.manager.CMServiceManager
getCMInfo, setCMInfo
-
Constructor Details
-
CMMqttManager
-
-
Method Details
-
connect
public boolean connect()Connects to the default server for the CM publish-subscribe service.A CM client that has logged in to the default server must call the connect() method before it uses the CM publish-subscribe service.
This method is same as connect(null,null,false,(byte)0, false,false,0) of theconnect(String, String, boolean, byte, boolean, boolean)
method.- Returns:
- true if the connect succeeds; false otherwise.
-
connect
public boolean connect(String strWillTopic, String strWillMessage, boolean bWillRetain, byte willQoS, boolean bWillFlag, boolean bCleanSession) Connects to the default server for the CM publish-subscribe service.A CM client that has logged in to the default server must call the connect() method before it uses the CM publish-subscribe service.
- Parameters:
strWillTopic
- - will topicstrWillMessage
- - will messagebWillRetain
- - will retainwillQoS
- - will QoSbWillFlag
- - will flagbCleanSession
- - clean session flag- Returns:
- true if the connect succeeds; false otherwise.
-
publish
Publishes a message.This method is the same as publish(strTopic, strMsg, (byte)0, false, false) of the
publish(String, String, byte, boolean, boolean)
method.- Parameters:
strTopic
- - topicstrMsg
- - message- Returns:
- true if the message is successfully published; false otherwise.
- See Also:
-
publish
Publishes a message.This method is the same as publish(strTopic, strMsg, qos, false, false) of the
publish(String, String, byte, boolean, boolean)
method.- Parameters:
strTopic
- - topicstrMsg
- - messageqos
- - QoS level- Returns:
- true if the message is successfully published; false otherwise.
- See Also:
-
publish
public boolean publish(String strTopic, String strMsg, byte qos, boolean bDupFlag, boolean bRetainFlag) Publishes a message.- Parameters:
strTopic
- - topicstrMsg
- - messageqos
- - QoS levelbDupFlag
- - DUP flagbRetainFlag
- - retain flag- Returns:
- true if the message is successfully published; false otherwise.
- See Also:
-
publishFromServerToOneClient
public boolean publishFromServerToOneClient(String strTopic, String strMsg, byte qos, boolean bDupFlag, boolean bRetainFlag, String strClient, CMMqttSession session) -
sendAndClearPendingTransPublish
-
resendSentUnAckPublish
-
resendSentUnAckPubrel
-
isTopicMatch
-
subscribe
Subscribes a topic filter.- Parameters:
strTopicFilter
- - topic filterqos
- - requested QoS level- Returns:
- true if the topic filter is successfully subscribed; false otherwise.
- See Also:
-
subscribe
Subscribes a list of topic filters.- Parameters:
topicQoSList
- - the list of topic filters- Returns:
- true if the topic filters are successfully subscribed; false otherwise.
- See Also:
-
unsubscribe
Unsubscribes a topic filter.- Parameters:
strTopic
- - the topic filter- Returns:
- true if the topic filter is successfully unsubscribed; false otherwise.
-
unsubscribe
Unsubscribes a list of topic filters.- Parameters:
topicList
- - the list of topic filters- Returns:
- true if the topic filters are successfully unsubscribed; false otherwise.
-
requestPing
public boolean requestPing() -
disconnect
public boolean disconnect()Disconnects the publish-subscribe service.This method only stops the publish-subscribe service, and the client can still continue to use the other CM services.
- Returns:
- true if the client successfully disconnects the publish-subscribe service; false otherwise.
-
getMySessionInfo
Returns the string that contains session information of a CM client.Only a CM client can call this method.
- Returns:
- the session information of the client.
-
getSessionInfo
Returns the string that contains session information of a CM client.Only a CM server can call this method.
- Parameters:
strUserName
- - the user (client) name- Returns:
- the session information of the user.
-
getAllSessionInfo
Returns the string that contains session information of all CM clients.Only a CM server can call this method.
- Returns:
- the all session information.
-
getAllRetainInfo
Returns all retain information.Only a CM server can call this method.
- Returns:
- the all retain information.
-
sendMqttWill
-