Initial submit

This commit is contained in:
Torsten Schulz
2017-07-18 23:51:56 +02:00
parent 071d70ecf6
commit 26ab29859d
13 changed files with 535 additions and 68 deletions

48
room.h
View File

@@ -1,17 +1,49 @@
#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 {
namespace Lib {
class Room
{
public:
Room();
};
class Server;
} // namespace Lib
class Room
{
public:
Room(Server *parent, std::string name, std::string password = "", std::vector<std::string> allowedUsers = std::vector<std::string>());
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
#endif // YC_LIB_ROOM_H