-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.cpp
44 lines (37 loc) · 859 Bytes
/
client.cpp
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
#include "client.h"
/**
* @brief Concrete client
* @param manager reference to mmanager
* @param username client's username
* @param address IP address
*/
Client::Client(ConnectionManager *manager, QString username, QHostAddress address)
{
// sets fields
this->username = username;
this->address = address;
this->manager = manager;
// add client to list
this->manager->addClient(this);
// timer to remove
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(removeMe()));
timer->setInterval(20000);
timer->start();
}
/**
* @brief Resets timer
*/
void Client::resetTimer() {
timer->stop();
timer->start();
}
/**
* @brief Removes client from list
*/
void Client::removeMe() {
//timer->stop();
manager->removeClient(this);
// TODO: review later
delete this;
}