diff --git a/user.cpp b/user.cpp index 2acfb76..a1bba28 100644 --- a/user.cpp +++ b/user.cpp @@ -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: