refactor: 복사 코드 함수화
This commit is contained in:
parent
1a7a4b7466
commit
2d35fd6c8b
3 changed files with 29 additions and 48 deletions
|
|
@ -3,6 +3,7 @@
|
|||
#include "SessionManager.h"
|
||||
#include <boost/asio/co_spawn.hpp>
|
||||
#include <boost/asio/detached.hpp>
|
||||
#include <cstring>
|
||||
|
||||
Session::Session(tcp::socket socket) : socket_(std::move(socket)) {}
|
||||
|
||||
|
|
@ -21,6 +22,15 @@ uint32_t Session::GetSwordLevel() const { return swordLevel_; }
|
|||
|
||||
void Session::Start() { DoReadHeader(); }
|
||||
|
||||
void Session::SendPacket(PacketID id) {
|
||||
PacketHeader header;
|
||||
header.id = static_cast<uint16_t>(id);
|
||||
header.size = 0;
|
||||
std::vector<uint8_t> buffer(sizeof(PacketHeader));
|
||||
std::memcpy(buffer.data(), &header, sizeof(PacketHeader));
|
||||
Send(buffer);
|
||||
}
|
||||
|
||||
void Session::Send(std::span<const uint8_t> data) {
|
||||
auto self(shared_from_this());
|
||||
boost::asio::post(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue