Files
yourchat/room.h
2017-07-21 21:49:19 +02:00

51 lines
1.4 KiB
C++

#ifndef YC_LIB_ROOM_H
#define YC_LIB_ROOM_H
#include <vector>
#include <string>
#include <user.h>
#include <queue>
#include <thread>
namespace Yc {
namespace Lib {
class Server;
class Room
{
public:
Room(Server *parent, std::string name, std::string password = "", std::vector<std::string> allowedUsers = std::vector<std::string>());
~Room();
void run();
std::string name();
bool addUser(std::string userName, std::string color, std::string password, int socket);
bool addUser(User *user, std::string password);
bool userNameExists(std::string userName);
void removeUser(std::string _token);
void setStop();
void addMessage(User::MsgType type, std::string message, std::string userName = "", std::string color = "");
private:
struct Message {
User::MsgType type;
std::string messageTr;
std::string userName;
std::string color;
};
Server *_parent;
std::string _name;
std::string _password;
std::vector<std::string> _allowedUsers;
std::vector<User*> _users;
bool _blocked;
bool _stop;
std::queue<Message> _msgQueue;
std::thread *thread;
};
} // namespace Lib
} // namespace Yc
#endif // YC_LIB_ROOM_H