Added user list for room

This commit is contained in:
Torsten Schulz
2017-08-04 14:47:55 +02:00
parent 48e2ff3885
commit 520f3106e3

View File

@@ -111,6 +111,7 @@ namespace Yc {
if (jsonTree["token"].asString() != _token) {
return;
}
std::cout << jsonTree["type"].asString() << std::endl;
if (jsonTree["type"].asString() == "message") {
checkString(jsonTree["message"].asString());
} else if (jsonTree["type"].asString() == "dice") {
@@ -121,6 +122,8 @@ namespace Yc {
_parent->addMessage(User::dosomething, jsonTree["message"].asString(), _name, _color);
} else if (jsonTree["type"].asString() == "join") {
changeRoom(jsonTree["newroom"].asString(), jsonTree["password"].asString());
} else if (jsonTree["type"].asString() == "userlist") {
sendUserList();
}
}
@@ -141,6 +144,13 @@ namespace Yc {
}
}
void User::sendUserList() {
Json::Value userList = _parent->userList();
Json::Value msg = Json::objectValue;
msg["userlist"] = userList;
sendMsg(userListe, msg, "", "");
}
void User::doDice() {
switch (_parent->addDice(this, (rand() % 6) + 1)) {
case 1: