Split CUserTimer into CIRCNetworkPingTimer and CIRCNetworkJoinTimer

This patch splits CUserTimer into two other timers:

CIRCNetworkPingTimer: This timer sends PING messages to connected
client's and IRC servers.

CIRCNetworkJoinTimer: This timer enforces the MaxJoin setting by only
allowing a specified amount of channels to join at the same time.

JoinChans() is modified to reset the ping timer once we hit the MaxJoin.
This allows us to call it from any function without breaking the timing
logic.
This commit is contained in:
Alexander Færøy
2014-05-30 01:06:14 +02:00
parent ef1639e7e0
commit 299f3aa637
3 changed files with 71 additions and 25 deletions

View File

@@ -36,30 +36,6 @@ public:
private:
protected:
virtual void RunJob() {
vector<CIRCNetwork*> vNetworks = m_pUser->GetNetworks();
for (size_t a = 0; a < vNetworks.size(); a++) {
CIRCNetwork* pNetwork = vNetworks[a];
CIRCSock* pIRCSock = pNetwork->GetIRCSock();
if (pIRCSock && pIRCSock->GetTimeSinceLastDataTransaction() >= 270) {
pIRCSock->PutIRC("PING :ZNC");
}
if (pNetwork->IsIRCConnected()) {
pNetwork->JoinChans();
}
vector<CClient*>& vClients = pNetwork->GetClients();
for (size_t b = 0; b < vClients.size(); b++) {
CClient* pClient = vClients[b];
if (pClient->GetTimeSinceLastDataTransaction() >= 270) {
pClient->PutClient("PING :ZNC");
}
}
}
vector<CClient*>& vUserClients = m_pUser->GetUserClients();
for (size_t c = 0; c < vUserClients.size(); ++c) {
CClient* pUserClient = vUserClients[c];