chatroom.h
1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef CHATROOM_H
#define CHATROOM_H
#include <QMainWindow>
#include "Socket.h"
#include "loginscreen.h"
#include <thread>
#include <mutex>
#include <condition_variable>
#include "chatwindow.h"
#include <map>
namespace Ui {
class Chatroom;
}
class Chatroom : public QMainWindow
{
Q_OBJECT
public:
explicit Chatroom(QWidget *parent = 0);
bool getConnected();
void setConnected(bool status);
void relayMsg(string& msg);
void setNickname(QString nick);
QString getNickname();
void putMsgToPrintQueue(string& msg);
~Chatroom();
public slots:
void startSession();
void sendMsg();
void printMsg();
private slots:
void finishThreads(bool exit);
void finish();
void disconnectChatroom();
signals:
void threadsFinished(bool exit);
void messagesToPrint();
private:
Ui::Chatroom *ui;
map<string,ChatWindow> activeChats;
bool connected;
string getSender(string& msg);
void putMsgToSendQueue(QString& msg);
std::thread *send;
std::thread *recv;
Socket s;
QString nickname;
list<string> printQueue;
};
void sendThread(Socket* s, Chatroom *chat);
void recvThread(Socket *s, Chatroom *chat);
#endif // CHATROOM_H