123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- //
- // Created by zx on 2020/8/28.
- //
- #ifndef NNXX_TESTS_MESSAGE_COMMUNICATOR_H
- #define NNXX_TESTS_MESSAGE_COMMUNICATOR_H
- #include "singleton.h"
- #include "communication_socket_base.h"
- #include "error_code.h"
- class Message_communicator :public Singleton<Message_communicator>, public Communication_socket_base
- {
- friend class Singleton<Message_communicator>;
- public:
- //必须关闭拷贝构造和赋值构造,只能通过 get_instance 函数来进行操作唯一的实例。
- Message_communicator(const Message_communicator& other) = delete;
- Message_communicator& operator =(const Message_communicator& other) = delete;
- /*
- * 发送消息
- */
- Error_manager send_msg(Communication_message* p_msg);
- ~Message_communicator();
- protected:
- // 父类的构造函数必须保护,子类的构造函数必须私有。
- Message_communicator();
- virtual Error_manager execute_msg(Communication_message* p_msg);
- /*
- * 检测消息是否可被处理
- */
- virtual Error_manager check_msg(Communication_message* p_msg);
- /*
- * 心跳发送函数,重载
- */
- virtual Error_manager encapsulate_send_data();
- //检查消息是否可以被解析, 需要重载
- virtual Error_manager check_executer(Communication_message* p_msg);
- };
- #endif //NNXX_TESTS_MESSAGE_COMMUNICATOR_H
|