Code refactoring

This commit is contained in:
Torsten Schulz
2017-10-12 14:49:07 +02:00
parent 520f3106e3
commit 57ec9c2cb6
5 changed files with 14 additions and 2 deletions

1
.gitignore vendored
View File

@@ -9,3 +9,4 @@
/user.o /user.o
/yourchat /yourchat
*.o *.o
*.qmake.stash

View File

@@ -1,8 +1,7 @@
#include "config.h" #include "config.h"
#include "server.h" #include "server.h"
int main(int, char **) int main(int, char **) {
{
Yc::Lib::Config *config = new Yc::Lib::Config(); Yc::Lib::Config *config = new Yc::Lib::Config();
Yc::Lib::Server server(config); Yc::Lib::Server server(config);
server.run(); server.run();

View File

@@ -149,6 +149,16 @@ namespace Yc {
return value; return value;
} }
Json::Value Room::userList() {
Json::Value users = Json::arrayValue;
for (auto &user: _users) {
Json::Value jsonUser = Json::objectValue;
jsonUser["name"] = user->name();
users.append(jsonUser);
}
return users;
}
Room::RoomType Room::type() { Room::RoomType Room::type() {
return _type; return _type;
} }

1
room.h
View File

@@ -48,6 +48,7 @@ namespace Yc {
void addUserWhenQueueEmpty(User *user); void addUserWhenQueueEmpty(User *user);
bool userToNewRoom(User *user, std::string newRoom, std::string password); bool userToNewRoom(User *user, std::string newRoom, std::string password);
unsigned int flags(); unsigned int flags();
Json::Value userList();
private: private:
struct Message { struct Message {
User::MsgType type; User::MsgType type;

1
user.h
View File

@@ -52,6 +52,7 @@ namespace Yc {
void doDice(); void doDice();
void changeRoom(std::string newRoom, std::string password); void changeRoom(std::string newRoom, std::string password);
void checkString(std::string message); void checkString(std::string message);
void sendUserList();
}; };
} // namespace Lib } // namespace Lib