43 lines
903 B
C++
43 lines
903 B
C++
#pragma once
|
|
|
|
#include "Packet.h"
|
|
#include <boost/asio.hpp>
|
|
#include <deque>
|
|
#include <memory>
|
|
#include <span>
|
|
|
|
using boost::asio::ip::tcp;
|
|
|
|
class Session : public std::enable_shared_from_this<Session> {
|
|
public:
|
|
Session(tcp::socket socket);
|
|
~Session();
|
|
|
|
void Start();
|
|
void Send(std::span<const uint8_t> data);
|
|
|
|
void SetNickname(const std::string &nickname);
|
|
const std::string &GetNickname() const;
|
|
|
|
void SetGold(uint64_t gold);
|
|
uint64_t GetGold() const;
|
|
|
|
void SetSwordLevel(uint32_t level);
|
|
uint32_t GetSwordLevel() const;
|
|
|
|
private:
|
|
void DoReadHeader();
|
|
void DoReadBody();
|
|
void DoWrite();
|
|
|
|
tcp::socket socket_;
|
|
PacketHeader packetHeader_;
|
|
std::vector<uint8_t> packetBody_;
|
|
|
|
// 스레드 안전성과 순서 보장을 위한 출력 패킷 큐
|
|
std::deque<std::vector<uint8_t>> writeQueue_;
|
|
|
|
std::string nickname_;
|
|
uint64_t gold_ = 0;
|
|
uint32_t swordLevel_ = 0;
|
|
};
|