tcpsockettimer.cpp

来自「《基于Symbian OS的手机开发与应用实践》这本书的配套源码。」· C++ 代码 · 共 64 行

CPP
64
字号
/*
* ============================================================================
*  Name     : CTcpSocketTimer from TcpSocketTimer.cpp
*  Part of  : Timer
*  Created  : 06.03.2006 by ToBeReplacedByAuthor
*  Implementation notes:
*     
*  Version  :
*  Copyright: ToBeReplacedByCopyright 
* ============================================================================
*/

// INCLUDES
#include "TcpSocketTimer.h"

// public standard construction sequence
CTcpSocketTimer* CTcpSocketTimer::NewL(MTimerObserver& aObserver)
    {
    CTcpSocketTimer* self = CTcpSocketTimer::NewLC(aObserver);
    CleanupStack::Pop();
    return self;
    }

CTcpSocketTimer* CTcpSocketTimer::NewLC(MTimerObserver& aObserver)
    {
    CTcpSocketTimer* self = new (ELeave) CTcpSocketTimer(aObserver);
    CleanupStack::PushL(self);
    self->ConstructL();
    return self;
    }

CTcpSocketTimer::~CTcpSocketTimer()
    {
    // No implementation required
    }

// public new functions
void CTcpSocketTimer::Start(TInt aSecond)
    {
    Cancel();
    After(aSecond * 1000000);
    }

// private standard construction sequence
CTcpSocketTimer::CTcpSocketTimer(MTimerObserver& aObserver)
:CTimer(EPriorityStandard),iObserver(aObserver)
    {
    // No implementation required
    }

void CTcpSocketTimer::ConstructL()
    {
    // This is explicitly decareded in the CTimer document
    CTimer::ConstructL();

    // The following line is also essencial!
    CActiveScheduler::Add(this);
    }

// private from CTimer
void CTcpSocketTimer::RunL()
    {
    iObserver.OnTimerL(iStatus.Int());
    }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?