일단 클라이언트 코드 채움

This commit is contained in:
2025-05-10 00:08:59 +09:00
parent 20f8c7b29d
commit be6ea6e92f
4 changed files with 73 additions and 6 deletions

View File

@@ -51,7 +51,7 @@ public:
void processDataPostPacket(DataPostPacket dataPostPacket, IOCPPASSINDATA* data);
void processContinuePacket(ContinuePacket continuePacket, IOCPPASSINDATA* data);
void registerUser(std::string userName, std::shared_ptr<TCPSocket> sock);
bool registerUser(std::string userName, std::shared_ptr<TCPSocket> sock);
void deleteUser(Snowflake UID);
std::vector<std::pair<Snowflake, std::string>> getUserList();
@@ -82,7 +82,7 @@ private:
std::unordered_map<std::shared_ptr<TCPSocket>, Snowflake> userSocket2UID_;
std::unordered_map<Snowflake, std::string> userNames_;
std::unordered_map<std::string, Snowflake> userName2ID_;
};

View File

@@ -418,10 +418,14 @@ void ServerManager::processContinuePacket(ContinuePacket continuePacket, IOCPPAS
}
}
void ServerManager::registerUser(std::string userName, std::shared_ptr<TCPSocket> sock) {
bool ServerManager::registerUser(std::string userName, std::shared_ptr<TCPSocket> sock) {
std::lock_guard<std::mutex> lock(resourceMutex_);
if (userName2ID_.find(userName) != userName2ID_.end()) {
return false;
}
Snowflake UID = GenerateID();
userNames_[UID] = userName;
userName2ID_[userName] = UID;
UID2userSocket_[UID] = sock;
userSocket2UID_[sock] = UID;
}