1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- //
- // Created by huli on 2022/12/30.
- //
- #ifndef NNXX_TESTS_NETWORK_MESSAGE_H
- #define NNXX_TESTS_NETWORK_MESSAGE_H
- #include "../error_code/error_code.h"
- #include <string>
- //网络通信的数据包,
- class Network_message
- {
- public:
- Network_message();
- Network_message(std::string message_buf, int socket_id, std::string ip, int port);
- Network_message(std::string message_buf, int socket_id = 0);
- Network_message(const Network_message& other)= default;
- Network_message& operator =(const Network_message& other)= default;
- ~Network_message();
- public://API functions
- void reset(std::string message_buf, int socket_id, std::string ip, int port);
- void reset(std::string message_buf, int socket_id = 0);
- public://get or set member variable
- protected://member functions
- protected://member variable
- public:
- //数据包属性
- int m_socket_id; //自定义的socket编号, 不能为0
- std::string m_ip; //连接的ip, 接受特有, 发送没有
- int m_port; //连接的端口, 接受特有, 发送没有
- //数据包内容
- std::string m_message_buf; //消息数据
- private:
- };
- #endif //NNXX_TESTS_NETWORK_MESSAGE_H
|