Added a timer to ping inactive clients

git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@670 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
prozacx
2006-02-26 09:42:13 +00:00
parent a9e60b43c5
commit b8c4fc760a
5 changed files with 34 additions and 1 deletions
+3
View File
@@ -864,6 +864,9 @@ public:
*/
virtual void ReadPaused() {}
//! return the duration since last write
int GetLastWriteDuration() { return m_iTcount; }
//! return the data imediatly ready for read
virtual int GetPending();
+25
View File
@@ -28,6 +28,31 @@ protected:
unsigned int m_uTrys;
};
class CMiscTimer : public CCron {
public:
CMiscTimer(CUser* pUser) : CCron() {
m_pUser = pUser;
Start(30);
}
virtual ~CMiscTimer() {}
private:
protected:
virtual void RunJob() {
vector<CClient*>& vClients = m_pUser->GetClients();
for (size_t a = 0; a < vClients.size(); a++) {
CClient* pClient = vClients[a];
if (pClient->GetLastWriteDuration() >= 470) {
pClient->PutClient("PING :ZNC");
}
}
}
CUser* m_pUser;
};
class CJoinTimer : public CCron {
public:
CJoinTimer(CUser* pUser) : CCron() {
+3
View File
@@ -38,8 +38,10 @@ CUser::CUser(const CString& sUserName) {
m_pAwayNickTimer = NULL;
m_pKeepNickTimer = new CKeepNickTimer(this);
m_pJoinTimer = new CJoinTimer(this);
m_pMiscTimer = new CMiscTimer(this);
CZNC::Get().GetManager().AddCron(m_pKeepNickTimer);
CZNC::Get().GetManager().AddCron(m_pJoinTimer);
CZNC::Get().GetManager().AddCron(m_pMiscTimer);
m_sUserPath = CZNC::Get().GetUserPath() + "/" + sUserName;
m_sDLPath = GetUserPath() + "/downloads";
}
@@ -60,6 +62,7 @@ CUser::~CUser() {
CZNC::Get().GetManager().DelCronByAddr(m_pAwayNickTimer);
CZNC::Get().GetManager().DelCronByAddr(m_pKeepNickTimer);
CZNC::Get().GetManager().DelCronByAddr(m_pJoinTimer);
CZNC::Get().GetManager().DelCronByAddr(m_pMiscTimer);
}
#ifdef _MODULES
+2
View File
@@ -24,6 +24,7 @@ class CBackNickTimer;
class CAwayNickTimer;
class CKeepNickTimer;
class CJoinTimer;
class CMiscTimer;
class CUser {
public:
@@ -206,6 +207,7 @@ protected:
CAwayNickTimer* m_pAwayNickTimer;
CKeepNickTimer* m_pKeepNickTimer;
CJoinTimer* m_pJoinTimer;
CMiscTimer* m_pMiscTimer;
vector<CServer*> m_vServers;
vector<CChan*> m_vChans;
+1 -1
View File
@@ -24,7 +24,6 @@ CZNC::CZNC() {
CZNC::~CZNC() {
#ifdef _MODULES
m_pModules->UnloadAll();
delete m_pModules;
for (map<CString,CUser*>::iterator a = m_msUsers.begin(); a != m_msUsers.end(); a++) {
a->second->GetModules().UnloadAll();
@@ -37,6 +36,7 @@ CZNC::~CZNC() {
m_Manager.Cleanup();
DeleteUsers();
delete m_pModules;
}
CString CZNC::GetTag(bool bIncludeVersion) {