-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.h
48 lines (40 loc) · 1.13 KB
/
client.h
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
#ifndef CLIENT_H
#define CLIENT_H
#include <QAbstractSocket>
#include <QHash>
#include <QHostAddress>
#include <QColor>
#include "mongochatneydefs.h"
#include "server.h"
class Connection;
class Client : public QObject
{
Q_OBJECT
public:
Client();
void sendMessage(const QString& msg);
QString userName() const;
bool hasConnection(const QHostAddress &senderIp, int senderPort = -1);
void initiateNewConnection(const QHostAddress &hostIp);
signals:
void newMessage(QColor, const QString &);
void newMongo(const QColor& name);
void mongoLeft(const QColor &name);
void stateChanged(State);
private slots:
void newConnection(Connection*connection);
void connectionError(QAbstractSocket::SocketError sError);
void disconnected();
void readyForUse();
private:
void removeConnection(Connection *connection);
QColor colorPick();
Server server;
QMap<Connection*, QColor> participants;
QMultiHash<QHostAddress, Connection *> peers;
QList<Connection*> connections;
QByteArray name;
signals:
void newConnectionInitiated(Connection *connection);
};
#endif // CLIENT_H