37 lines
995 B
C++
37 lines
995 B
C++
#ifndef YP_LIB_SERVER_H
|
|
#define YP_LIB_SERVER_H
|
|
|
|
#include "config.h"
|
|
#include <vector>
|
|
#include "room.h"
|
|
#include "base.h"
|
|
#include <json/value.h>
|
|
|
|
namespace Yc {
|
|
namespace Lib {
|
|
|
|
class Server: public Base
|
|
{
|
|
public:
|
|
Server(Yc::Lib::Config *config);
|
|
void run();
|
|
std::vector<std::string> roomList();
|
|
Json::Value jsonRoomList();
|
|
bool roomAllowed(std::string roomName, std::string userName, std::string password);
|
|
private:
|
|
int _socket;
|
|
Yc::Lib::Config *_config;
|
|
bool _stop;
|
|
std::vector<Yc::Lib::Room*> _rooms;
|
|
void createRooms(Json::Value roomList);
|
|
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
|