| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- #pragma once
- #include "../pch/pch.h"
- #include "PosMessage.h"
- using boost::asio::ip::tcp;
- class CServer;
- class CClientSession
- {
- public:
- CClientSession(boost::asio::io_context& io_context)
- : socket_(io_context)
- {
- }
- ~CClientSession();
- void SetServer(CServer* server);
- tcp::socket& socket()
- {
- return socket_;
- }
- void start();
- void stop();
- bool send_message(std::string msg);
- void SetNum(int m_num)
- {
- m_nClientNum = m_num;
- }
- int GetNum()
- {
- return m_nClientNum;
- }
- private:
- void handle_read(const boost::system::error_code& error,
- size_t bytes_transferred);
- tcp::socket socket_;
-
- PosMessage m_pos_message;
- CServer* m_server;
- int m_nClientNum = 0;
- //本连接对应的客户端用户名
- std::string m_username = "";
- bool is_stop_work = false;
- std::mutex stop_mutex;
- };
|