Receive and send messages

This commit is contained in:
Torsten Schulz
2017-07-21 21:49:19 +02:00
parent 922ee7ac12
commit b5b4c94f65
10 changed files with 144 additions and 44 deletions

10
user.h
View File

@@ -3,15 +3,18 @@
#include <string>
#include <json/json.h>
#include <thread>
#include "base.h"
namespace Yc {
namespace Lib {
class Room;
class User {
class User: public Base {
public:
enum MsgType {
error = -1,
token = 1,
userListe = 2,
roomList = 3,
@@ -20,6 +23,7 @@ namespace Yc {
};
User(Room *parent, std::string name, std::string color, int socket);
~User();
std::string name() const;
bool validateToken(std::string token);
bool isUser(User *toValidate);
@@ -35,6 +39,10 @@ namespace Yc {
int _socket;
std::string _token;
bool _stop;
std::thread *thread;
void send(std::string out);
void send(Json::Value out);
void handleMessage(std::string message);
};
} // namespace Lib