#ifndef YP_LIB_SERVER_H #define YP_LIB_SERVER_H #include "config.h" #include "database.h" #include #include "room.h" #include "base.h" #include namespace Yc { namespace Lib { class Server: public Base, public std::enable_shared_from_this { public: Server(std::shared_ptr config, std::shared_ptr database); void run(); std::vector roomList(); Json::Value jsonRoomList(); bool roomAllowed(std::string roomName, std::string userName, std::string password); bool changeRoom(std::shared_ptr user, std::string newRoom, std::string password); int _socket; std::shared_ptr _config; std::shared_ptr _database; bool _stop; std::vector> _rooms; void createRooms(Json::Value roomList); private: void handleRequest(); void inputSwitcher(int userSocket, std::string input); bool userExists(std::string userName); void initUser(int userSocket, Json::Value data); }; } // namespace Lib } // namespace Yp #endif // YP_LIB_SERVER_H