Files
znc/Timers.h
T
silverleo 3ae8d389c6 It's 2010, where's my hoverboard?
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1693 726aef4b-f618-498e-8847-2d620e286838
2010-01-06 09:37:05 +00:00

52 lines
1.1 KiB
C++

/*
* Copyright (C) 2004-2010 See the AUTHORS file for details.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*/
#ifndef _TIMERS_H
#define _TIMERS_H
#include "Client.h"
#include "IRCSock.h"
#include "User.h"
class CUserTimer : public CCron {
public:
CUserTimer(CUser* pUser) : CCron() {
m_pUser = pUser;
SetName("CUserTimer::" + m_pUser->GetUserName());
Start(30);
}
virtual ~CUserTimer() {}
private:
protected:
virtual void RunJob() {
vector<CClient*>& vClients = m_pUser->GetClients();
CIRCSock* pIRCSock = m_pUser->GetIRCSock();
if (pIRCSock && pIRCSock->GetTimeSinceLastDataTransaction() >= 180) {
pIRCSock->PutIRC("PING :ZNC");
}
for (size_t a = 0; a < vClients.size(); a++) {
CClient* pClient = vClients[a];
if (pClient->GetTimeSinceLastDataTransaction() >= 180) {
pClient->PutClient("PING :ZNC");
}
}
if (m_pUser->IsIRCConnected()) {
m_pUser->JoinChans();
}
}
CUser* m_pUser;
};
#endif // !_TIMERS_H