public static void onTimerHandler(object sender, EventArgs e) { NetSceneDownloadVoice voice = TimerEventArgs.getObject(e) as NetSceneDownloadVoice; if (voice == null) { Log.e("NetSceneDownloadVoice", "onTimerHandler, invalid timer args"); } else if (voice.mVoiceContext == null) { Log.d("NetSceneDownloadVoice", "scene.mVoiceContext is null,doScene already finished"); } else if (voice.mVoiceContext.isBlockRunning()) { Log.d("NetSceneDownloadVoice", "doScene recving msg block now status=" + voice.mVoiceContext.mStatus); } else { Log.i("NetSceneDownloadVoice", "doScene start download msg block now status=" + voice.mVoiceContext.mStatus); MsgTrans currentVoiceBlock = voice.mVoiceContext.GetCurrentVoiceBlock(); if (currentVoiceBlock == null) { if (voice.mTimerObject.FireCount > 300) { Log.e("NetSceneDownloadVoice", "the block timer reached the max times = " + 300); voice.doSceneFinished(5); voice.cancel(); } } else { voice.doSceneBlock(currentVoiceBlock); } } }
public static void onVoiceContextDispatcher(object sender, EventArgs e) { DownloadVoiceContextMgr.getInstance().clearnFinishedContext(); //if (DownloadVoiceContextMgr.getInstance().getCount() <= 0) //{ // DownloadVoiceStorage.loadDownloadVoiceContextList(); //} if (DownloadVoiceContextMgr.getInstance().getCount() <= 0) { Log.i("DownloadVoiceService", "all ready, close dispatcher timer. "); if (isFirstSync) { ServiceCenter.sceneNewSync.unsetRecvMsgStatus(RecvMsgStatus.isRecvVoice); //EventCenter.postEvent(EventConst.ON_NETSCENE_DOWNLOADVOICE_SERVICE_FINISH, null, null); isFirstSync = false; } //if (isAppActive) //{ // ServiceCenter.sceneNewSync.unsetRecvMsgStatus(RecvMsgStatus.isRecvVoice); // EventCenter.postEvent(EventConst.ON_NETSCENE_DOWNLOADVOICE_SERVICE_FINISH, null, null); // isAppActive = false; //} if (mTimerObject != null) { mTimerObject.stop(); mTimerObject = null; } } else { int num = DownloadVoiceContextMgr.getInstance().countRunningContext(); int num2 = (int)getDownloadPackNum(); if (num >= num2) { Log.i("DownloadVoiceService", "return request, because reach MaxRunningNum = " + num2); } else { for (int i = 0; i < (num2 - num); i++) { DownloadVoiceContext voiceContext = DownloadVoiceContextMgr.getInstance().getFirstContextNeedHandle(); if (voiceContext == null) { return; } Log.i("DownloadVoiceService", "new task startup, mMsgSvrID = " + voiceContext.mMsgSvrID); NetSceneDownloadVoice voice = new NetSceneDownloadVoice(); voice.mOnSceneFinished += new onSceneDownloadFinishedDelegate(DownloadVoiceService.onSceneFinished); voice.doScene(voiceContext); } } } }