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 TypeMethodDescriptionbooleanconnect()Connects to the default server for the CM publish-subscribe service.booleanconnect(String strWillTopic, String strWillMessage, boolean bWillRetain, byte willQoS, boolean bWillFlag, boolean bCleanSession) Connects to the default server for the CM publish-subscribe service.booleanDisconnects 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 booleanisTopicMatch(String strTopic, String strFilter) booleanPublishes a message.booleanPublishes a message.booleanPublishes a message.booleanpublishFromServerToOneClient(String strTopic, String strMsg, byte qos, boolean bDupFlag, boolean bRetainFlag, String strClient, CMMqttSession session) booleanbooleanresendSentUnAckPublish(String strReceiver, CMMqttSession session) booleanresendSentUnAckPubrel(String strReceiver, CMMqttSession session) booleansendAndClearPendingTransPublish(String strReceiver, CMMqttSession session) booleansendMqttWill(String strUser) booleanSubscribes a topic filter.booleansubscribe(CMList<CMMqttTopicQoS> topicQoSList) Subscribes a list of topic filters.booleanunsubscribe(String strTopic) Unsubscribes a topic filter.booleanunsubscribe(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
-