浏览代码

Rename Message and Cleanup

JDierkse 5 年之前
父节点
当前提交
8422bc503d
共有 5 个文件被更改,包括 14 次插入13 次删除
  1. 2 1
      MQTT/MQTT.cpp
  2. 2 2
      MQTT/MQTTImpl.cpp
  3. 3 3
      MQTT/MQTTImpl.h
  4. 3 3
      include/MQTT.h
  5. 4 4
      include/MQTTMessage.h

+ 2 - 1
MQTT/MQTT.cpp

@@ -13,7 +13,7 @@ MQTT::~MQTT()
 {
 }
 
-bool MQTT::Send(const Message& message)
+bool MQTT::Send(const MQTTMessage& message)
 {
 	return m_pMQTTImpl->Send(message);
 }
@@ -39,3 +39,4 @@ void MQTT::Disconnect(size_t connection)
 }
 
 } // namespace MQTT
+

+ 2 - 2
MQTT/MQTTImpl.cpp

@@ -32,7 +32,7 @@ MQTTImpl::~MQTTImpl()
 	mosquitto_lib_cleanup();
 }
 
-bool MQTTImpl::Send(const Message& message)
+bool MQTTImpl::Send(const MQTTMessage& message)
 {
 	if (m_connected)
 		return (MOSQ_ERR_SUCCESS == mosquitto_publish(m_pMosquitto, NULL, message.topic.c_str(), message.payload.length(), message.payload.c_str(), 0, 0));
@@ -154,7 +154,7 @@ void MQTTImpl::ConnectCallback(int result)
 
 void MQTTImpl::MessageCallback(const mosquitto_message* pMessage)
 {
-	Message message;
+	MQTTMessage message;
 	message.topic = std::string(pMessage->topic);
 	message.payload = std::string(static_cast<char*>(pMessage->payload), pMessage->payloadlen);
 

+ 3 - 3
MQTT/MQTTImpl.h

@@ -1,8 +1,8 @@
 #ifndef MQTT_MQTTIMPL_H
 #define MQTT_MQTTIMPL_H
 
-#include "Message.h"
 #include "MQTT.h"
+#include "MQTTMessage.h"
 #include <SimpleSignal.h>
 #include <mutex>
 #include <string>
@@ -20,14 +20,14 @@ public:
 	MQTTImpl(const std::string& hostname, int port);
 	~MQTTImpl();
 
-	bool Send(const Message& message);
+	bool Send(const MQTTMessage& message);
 	bool Subscribe(const std::string& topic);
 	void Unsubscribe(const std::string& topic);
 	size_t Connect(MQTT::CallbackMethod function);
 	void Disconnect(size_t connection);
 
 private:
-	typedef Simple::Signal<void(const Message&)> MessageSignal;
+	typedef Simple::Signal<void(const MQTTMessage&)> MessageSignal;
 
 private:
 	static void ConnectCallback(mosquitto* pMosquitto, void* pObject, int result);

+ 3 - 3
include/MQTT.h

@@ -1,7 +1,7 @@
 #ifndef MQTT_H
 #define MQTT_H
 
-#include "Message.h"
+#include "MQTTMessage.h"
 #include <functional>
 #include <memory>
 #include <string>
@@ -18,10 +18,10 @@ public:
 	~MQTT();
 
 public:
-	typedef std::function<void(const Message&)> CallbackMethod;
+	typedef std::function<void(const MQTTMessage&)> CallbackMethod;
 
 public:
-	bool Send(const Message& message);
+	bool Send(const MQTTMessage& message);
 	bool Subscribe(const std::string& topic);
 	void Unsubscribe(const std::string& topic);
 	size_t Connect(CallbackMethod function);

+ 4 - 4
include/Message.h → include/MQTTMessage.h

@@ -1,12 +1,12 @@
-#ifndef MESSAGE_H
-#define MESSAGE_H
+#ifndef MQTTMESSAGE_H
+#define MQTTMESSAGE_H
 
 #include <string>
 
 
 namespace MQTT {
 
-struct Message
+struct MQTTMessage
 {
 	std::string topic;
 	std::string payload;
@@ -14,4 +14,4 @@ struct Message
 
 } // namespace MQTT
 
-#endif // MESSAGE_H
+#endif // MQTTMESSAGE_H