Code refactoring
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -9,3 +9,4 @@
|
||||
/user.o
|
||||
/yourchat
|
||||
*.o
|
||||
*.qmake.stash
|
||||
|
||||
3
main.cpp
3
main.cpp
@@ -1,8 +1,7 @@
|
||||
#include "config.h"
|
||||
#include "server.h"
|
||||
|
||||
int main(int, char **)
|
||||
{
|
||||
int main(int, char **) {
|
||||
Yc::Lib::Config *config = new Yc::Lib::Config();
|
||||
Yc::Lib::Server server(config);
|
||||
server.run();
|
||||
|
||||
10
room.cpp
10
room.cpp
@@ -149,6 +149,16 @@ namespace Yc {
|
||||
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() {
|
||||
return _type;
|
||||
}
|
||||
|
||||
1
room.h
1
room.h
@@ -48,6 +48,7 @@ namespace Yc {
|
||||
void addUserWhenQueueEmpty(User *user);
|
||||
bool userToNewRoom(User *user, std::string newRoom, std::string password);
|
||||
unsigned int flags();
|
||||
Json::Value userList();
|
||||
private:
|
||||
struct Message {
|
||||
User::MsgType type;
|
||||
|
||||
Reference in New Issue
Block a user