Room change, room list with flags
This commit is contained in:
10
user.cpp
10
user.cpp
@@ -77,6 +77,8 @@ namespace Yc {
|
||||
if (selectResult == 1 && FD_ISSET(_socket, &readSd) == 1) {
|
||||
_parent->removeUser(_token);
|
||||
_stop = true;
|
||||
delete this;
|
||||
return;
|
||||
}
|
||||
std::string msg = readSocket(_socket);
|
||||
if (msg == "") {
|
||||
@@ -113,6 +115,8 @@ namespace Yc {
|
||||
_parent->addMessage(User::scream, jsonTree["message"].asString(), _name, _color);
|
||||
} else if (jsonTree["type"].asString() == "do") {
|
||||
_parent->addMessage(User::dosomething, jsonTree["message"].asString(), _name, _color);
|
||||
} else if (jsonTree["type"].asString() == "join") {
|
||||
changeRoom(jsonTree["newroom"].asString(), jsonTree["password"].asString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,5 +132,11 @@ namespace Yc {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void User::changeRoom(std::string newRoom, std::string password) {
|
||||
if (!_parent->userToNewRoom(this, newRoom, password)) {
|
||||
sendMsg(User::system, "room_not_possible", "", "");
|
||||
}
|
||||
}
|
||||
} // namespace Lib
|
||||
} // namespace Yc
|
||||
|
||||
Reference in New Issue
Block a user