Room change, room list with flags

This commit is contained in:
Torsten Schulz
2017-07-24 23:41:12 +02:00
parent 105232a9e3
commit b9d2b3e347
6 changed files with 102 additions and 7 deletions

View File

@@ -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