implement heartbeat timer required for relay

This commit is contained in:
ehouse 2005-10-06 02:49:50 +00:00
parent be5078e8f8
commit 07a1894c6e
2 changed files with 57 additions and 8 deletions

View file

@ -118,7 +118,7 @@ class CXWordsAppView : public CCoeControl
EUtilRequest
, EProcessPacket
, ENumReasons
} XWTimerReason ;
} XWTimerReason_symb ;
/* open game from prefs or start a new one. */
void MakeOrLoadGameL();
@ -145,7 +145,7 @@ class CXWordsAppView : public CCoeControl
TBool DoNewGame();
void DoImmediateDraw();
void DrawGameName() const;
void StartIdleTimer( XWTimerReason aWhy );
void StartIdleTimer( XWTimerReason_symb aWhy );
static void sym_util_requestTime( XW_UtilCtxt* uc );
static VTableMgr* sym_util_getVTManager( XW_UtilCtxt* uc );
@ -162,6 +162,9 @@ class CXWordsAppView : public CCoeControl
static void sym_util_addrChange( XW_UtilCtxt* uc,
const CommsAddrRec* aOld,
const CommsAddrRec* aNew );
static void sym_util_setTimer( XW_UtilCtxt* uc,
XWTimerReason why, XP_U16 when,
TimerProc proc, void* closure );
#endif
#ifdef XWFEATURE_STANDALONE_ONLY
@ -178,6 +181,14 @@ class CXWordsAppView : public CCoeControl
#endif
static TInt TimerCallback( TAny* aThis );
static TInt HeartbeatTimerCallback( TAny* closure );
void SetHeartbeatCB( TimerProc aHBP, void* aHBC) {
iHeartbeatProc =aHBP; iHeartbeatClosure = aHBC;
}
void GetHeartbeatCB( TimerProc* aHBP, void** aHBC) {
*aHBP = iHeartbeatProc; *aHBC = iHeartbeatClosure;
}
CEikApplication* iApp; /* remove if there's some way to get from
env */
@ -202,6 +213,14 @@ class CXWordsAppView : public CCoeControl
CDesC16ArrayFlat* iDictList; /* to pass into the dialog */
CDeltaTimer* iDeltaTimer;
TimerProc iHeartbeatProc;
void* iHeartbeatClosure;
TCallBack iHeartbeatCB;
TDeltaTimerEntry iHeartbeatDTE;
XP_Bool iHBQueued;
#ifndef XWFEATURE_STANDALONE_ONLY
CSendSocket* iSendSock;
CDesC8ArrayFlat* iNewPacketQueue;
@ -210,5 +229,4 @@ class CXWordsAppView : public CCoeControl
MPSLOT
};
#endif // _XWORDSAPPVIEW_H_

View file

@ -69,6 +69,9 @@ CXWordsAppView* CXWordsAppView::NewLC(const TRect& aRect, CEikApplication* aApp
CXWordsAppView::CXWordsAppView( CEikApplication* aApp )
: iApp( aApp )
, iHeartbeatCB( HeartbeatTimerCallback, this )
, iHeartbeatDTE(iHeartbeatCB)
, iHBQueued(XP_FALSE)
{
#ifdef DEBUG
TInt processHandleCount, threadHandleCount;
@ -134,6 +137,8 @@ void CXWordsAppView::ConstructL(const TRect& aRect)
iRequestTimer = CIdle::NewL( CActive::EPriorityIdle );
iTimerRunCount = 0;
iDeltaTimer = CDeltaTimer::NewL( CActive::EPriorityStandard );
#ifndef XWFEATURE_STANDALONE_ONLY
iSendSock = CSendSocket::NewL( PacketReceived, (void*)this );
@ -362,7 +367,8 @@ sym_util_trayHiddenChange(XW_UtilCtxt* /*uc*/, XW_TrayVisState /*newState*/ )
}
static void
sym_util_yOffsetChange(XW_UtilCtxt* /*uc*/, XP_U16 /*oldOffset*/, XP_U16 /*newOffset*/ )
sym_util_yOffsetChange(XW_UtilCtxt* /*uc*/, XP_U16 /*oldOffset*/,
XP_U16 /*newOffset*/ )
{
}
@ -388,10 +394,35 @@ sym_util_engineProgressCallback( XW_UtilCtxt* /*uc*/ )
return XP_TRUE;
}
static void
sym_util_setTimer( XW_UtilCtxt* /*uc*/, XWTimerReason /*why*/, XP_U16 /*when*/,
TimerProc /* proc */, void* /* closure */ )
/*static*/ TInt
CXWordsAppView::HeartbeatTimerCallback( TAny* closure )
{
CXWordsAppView* self = (CXWordsAppView*)closure;
self->iHBQueued = XP_FALSE;
TimerProc proc;
void* hbclosure;
self->GetHeartbeatCB( &proc, &hbclosure );
(*proc)( hbclosure, TIMER_HEARTBEAT );
return 0;
}
/* static */ void
CXWordsAppView::sym_util_setTimer( XW_UtilCtxt* uc, XWTimerReason why,
XP_U16 when,
TimerProc proc, void* closure )
{
CXWordsAppView* self = (CXWordsAppView*)uc->closure;
self->SetHeartbeatCB( proc, closure );
if ( self->iHBQueued ) {
self->iDeltaTimer->Remove( self->iHeartbeatDTE );
self->iHBQueued = XP_FALSE;
}
self->iDeltaTimer->Queue( when * 1000000, self->iHeartbeatDTE );
self->iHBQueued = XP_TRUE;
}
/* static */ void
@ -1330,7 +1361,7 @@ CXWordsAppView::sym_send_on_close( XWStreamCtxt* aStream, void* aClosure )
#endif
void
CXWordsAppView::StartIdleTimer( XWTimerReason aWhy )
CXWordsAppView::StartIdleTimer( XWTimerReason_symb aWhy )
{
++iTimerReasons[aWhy];