-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconnectionmanager.h
68 lines (58 loc) · 1.66 KB
/
connectionmanager.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef CONNECTIONMANAGER_H
#define CONNECTIONMANAGER_H
#include <QtWidgets>
#include <QtNetwork>
#include <mipconfig.h>
#include "mipavcodecencoder.h"
#include <mipaudiosession.h>
#include <mippainputoutput.h>
#include <iostream>
#include <jrtplib3/rtpipv4address.h>
using namespace jrtplib;
#include "client.h"
#include "mainwindow.h"
class MainWindow;
class Client;
/*
* @brief A concrete implementation of the Manager interface
*/
class ConnectionManager : public QObject, MIPAudioSession
{
Q_OBJECT
public:
ConnectionManager(MainWindow *window);
QHash<QHostAddress, Client *> hosts;
public slots:
void addClient(Client *client);
void removeClient(Client *client);
void sendMessage(QString msg);
void sendPrivateMessage(QString msg, QHostAddress address);
void call();
void hangup();
QHostAddress getIPbyNickname(QString nickname);
private slots:
void datagramListener();
bool lengthValidator(int length, QString string);
void refreshChatters();
void ping();
void sayHi();
void checkRet(bool ret, const MIPErrorBase &obj);
QString getNicknameByIP(QHostAddress address);
private:
MainWindow *window;
QUdpSocket *udpSocket = nullptr;
QTimer *ticker;
QHash<QHostAddress, QString> chattersList;
QHash<QHostAddress, int> timeList;
const QString P_TYPE = "EVMp";
const QString P_CONNECT = "CONNECT";
const QString P_ALIVE = "ALIVE";
const QString P_SENDMESSAGE = "SENDMSG";
const QString P_PRIVATEMSG = "PRIVATEMSG";
const char sep = '_';
bool flag = true;
QTimer *timer;
MIPAudioSession audioSess;
QHostAddress privateAddress;
};
#endif // CONNECTIONMANAGER_H