#ifndef CHATROOM_H #define CHATROOM_H #include #include #include #include #include #include #include "loginscreen.h" #include "chatwindow.h" #include "Socket.h" namespace Ui { class Chatroom; } class Chatroom : public QMainWindow { Q_OBJECT public: explicit Chatroom(QWidget *parent = 0); bool getConnected(); void setConnected(bool status); QString getNickname(); void setNickname(QString nick); void updateUserList(QString userlist); void relayMsg(string msg); void removeChat(QString &nickname); void putMsgToPrintQueue(string& msg); void putMsgToSendQueue(QString& msg); ~Chatroom(); private: Ui::Chatroom *ui; Socket s; bool connected; std::thread *send; std::thread *recv; QString nickname; list printQueue; map activeChats; std::mutex chatMutex; unique_lock* chatLock; std::condition_variable chatCreated; string getSender(string msg); private slots: void newChat(QString peerNick); protected: void closeEvent(QCloseEvent *event); public slots: void startSession(); void sendMsg(); void disconnectChatroom(); void launchChatWindow(QModelIndex index); private slots: void printMsg(); signals: void messagesToPrint(); void createChat(QString sender); }; void sendThread(Socket* s, Chatroom *chat); void recvThread(Socket *s, Chatroom *chat); #endif // CHATROOM_H