Refactor Server class: move createRooms call outside constructor and update access modifier for _socket
This commit is contained in:
1
main.cpp
1
main.cpp
@@ -5,6 +5,7 @@
|
||||
int main(int, char **) {
|
||||
auto config = std::make_shared<Yc::Lib::Config>();
|
||||
auto server = std::make_shared<Yc::Lib::Server>(config);
|
||||
server->createRooms(config->group("rooms"));
|
||||
server->run();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Yc {
|
||||
std::cout << "bind not possible" << std::endl;
|
||||
exit(-1);
|
||||
}
|
||||
createRooms(_config->group("rooms"));
|
||||
// createRooms wird jetzt außerhalb des Konstruktors aufgerufen
|
||||
}
|
||||
|
||||
void Server::run() {
|
||||
|
||||
3
server.h
3
server.h
@@ -19,12 +19,13 @@ namespace Yc {
|
||||
Json::Value jsonRoomList();
|
||||
bool roomAllowed(std::string roomName, std::string userName, std::string password);
|
||||
bool changeRoom(std::shared_ptr<User> user, std::string newRoom, std::string password);
|
||||
private:
|
||||
public:
|
||||
int _socket;
|
||||
std::shared_ptr<Yc::Lib::Config> _config;
|
||||
bool _stop;
|
||||
std::vector<std::shared_ptr<Yc::Lib::Room>> _rooms;
|
||||
void createRooms(Json::Value roomList);
|
||||
private:
|
||||
void handleRequest();
|
||||
void inputSwitcher(int userSocket, std::string input);
|
||||
bool userExists(std::string userName);
|
||||
|
||||
Reference in New Issue
Block a user