| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #pragma once
- #include "../pch/pch.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();
- void 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);
- void handle_write(const boost::system::error_code& error);
- tcp::socket socket_;
- enum { max_length = 1024 };
- char data_[max_length];
- CServer* m_server;
- int m_nClientNum;
- std::string m_username = "";
- };
|