Unify CJoinTimer and CMiscTimer to CUserTimer

The CJoinTimer which fired every 20s made the user try to join channels if there
were still some channels pending.

The CMiscTimer checked every 30s if a irc or client socket is near its timeout
and sent a "PING" if it was.

The new CUserTimer now does both every 30s.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1623 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2009-09-10 10:50:48 +00:00
parent edb6c42dd8
commit 5fea8a69c1
3 changed files with 9 additions and 30 deletions

View File

@@ -13,14 +13,14 @@
#include "IRCSock.h"
#include "User.h"
class CMiscTimer : public CCron {
class CUserTimer : public CCron {
public:
CMiscTimer(CUser* pUser) : CCron() {
CUserTimer(CUser* pUser) : CCron() {
m_pUser = pUser;
SetName("CMiscTimer::" + m_pUser->GetUserName());
SetName("CUserTimer::" + m_pUser->GetUserName());
Start(30);
}
virtual ~CMiscTimer() {}
virtual ~CUserTimer() {}
private:
protected:
@@ -39,23 +39,7 @@ protected:
pClient->PutClient("PING :ZNC");
}
}
}
CUser* m_pUser;
};
class CJoinTimer : public CCron {
public:
CJoinTimer(CUser* pUser) : CCron() {
m_pUser = pUser;
SetName("CJoinTimer::" + m_pUser->GetUserName());
Start(20);
}
virtual ~CJoinTimer() {}
private:
protected:
virtual void RunJob() {
if (m_pUser->IsIRCConnected()) {
m_pUser->JoinChans();
}

View File

@@ -48,10 +48,8 @@ CUser::CUser(const CString& sUserName) {
m_bAppendTimestamp = false;
m_bPrependTimestamp = true;
m_bIRCConnectEnabled = true;
m_pJoinTimer = new CJoinTimer(this);
m_pMiscTimer = new CMiscTimer(this);
CZNC::Get().GetManager().AddCron(m_pJoinTimer);
CZNC::Get().GetManager().AddCron(m_pMiscTimer);
m_pUserTimer = new CUserTimer(this);
CZNC::Get().GetManager().AddCron(m_pUserTimer);
m_sUserPath = CZNC::Get().GetUserPath() + "/" + sUserName;
m_sDLPath = GetUserPath() + "/downloads";
}
@@ -76,8 +74,7 @@ CUser::~CUser() {
while (!m_sDCCSocks.empty())
CZNC::Get().GetManager().DelSockByAddr((CZNCSock*) *m_sDCCSocks.begin());
CZNC::Get().GetManager().DelCronByAddr(m_pJoinTimer);
CZNC::Get().GetManager().DelCronByAddr(m_pMiscTimer);
CZNC::Get().GetManager().DelCronByAddr(m_pUserTimer);
}
#ifdef _MODULES

6
User.h
View File

@@ -24,8 +24,7 @@ using std::vector;
class CChan;
class CClient;
class CIRCSock;
class CJoinTimer;
class CMiscTimer;
class CUserTimer;
class CServer;
class CDCCBounce;
class CDCCSock;
@@ -265,8 +264,7 @@ protected:
bool m_bIRCConnectEnabled;
CIRCSock* m_pIRCSock;
CJoinTimer* m_pJoinTimer;
CMiscTimer* m_pMiscTimer;
CUserTimer* m_pUserTimer;
vector<CServer*> m_vServers;
vector<CChan*> m_vChans;