일단 클라이언트 코드 채움
This commit is contained in:
@@ -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_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user