Code refactoring
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -9,3 +9,4 @@
|
|||||||
/user.o
|
/user.o
|
||||||
/yourchat
|
/yourchat
|
||||||
*.o
|
*.o
|
||||||
|
*.qmake.stash
|
||||||
|
|||||||
3
main.cpp
3
main.cpp
@@ -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();
|
||||||
|
|||||||
10
room.cpp
10
room.cpp
@@ -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
1
room.h
@@ -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
1
user.h
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user