init
This commit is contained in:
commit
b887f15662
21 changed files with 1038 additions and 0 deletions
43
include/Session.h
Normal file
43
include/Session.h
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#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;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue