Blame view

QChatClient/chatroom.h 1.2 KB
1
2
3
4
#ifndef CHATROOM_H
#define CHATROOM_H

#include <QMainWindow>
5
#include "Socket.h"
6
7
8
9
10
11
#include "loginscreen.h"
#include <thread>
#include <mutex>
#include <condition_variable>
#include "chatwindow.h"
#include <map>
12
13
14
15
16
17
18
19
20
21
22

namespace Ui {
class Chatroom;
}

class Chatroom : public QMainWindow
{
    Q_OBJECT

public:
    explicit Chatroom(QWidget *parent = 0);
23
24
25
26
27
28
    bool getConnected();
    void setConnected(bool status);
    void relayMsg(string& msg);
    void setNickname(QString nick);
    QString getNickname();
    void putMsgToPrintQueue(string& msg);
29
    ~Chatroom();
30
31
32
33
34
35
36
37
38
39
40
41
42
43

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();
44
45
46

private:
    Ui::Chatroom *ui;
47
    map<string,ChatWindow> activeChats;
48
    bool connected;
49
50
51
52
53
54
55
    string getSender(string& msg);
    void putMsgToSendQueue(QString& msg);
    std::thread *send;
    std::thread *recv;
    Socket s;
    QString nickname;
    list<string> printQueue;
56
57
};
58
59
void sendThread(Socket* s, Chatroom *chat);
void recvThread(Socket *s, Chatroom *chat);
60
61
#endif // CHATROOM_H