void CBoxManMain::WinOrNot(void) { if (IsFinish()) { m_pBoxManWnd->Invalidate(FALSE); m_SoundState=SOUND_STATE_VICTORY; BoxManPlaySound(); AfxMessageBox("恭喜!\n您已通过该关!"); //Sleep(1000); DispatchMsg(113); } }
void DispatchMsgListToPCB(T_MSG* ptMsgList,WORD16 dwTno) { T_MSG* ptNextMsg = NULL; while (NULL != ptMsgList) { ptNextMsg = ptMsgList->ptNextMsg; ptMsgList->ptNextMsg = NULL; DispatchMsg(ptMsgList, dwTno); ptMsgList = ptNextMsg; } }
BOOLEAN SendInCPU(BYTE *pucMsgPtr,WORD32 dwParam) { T_MSG *ptMsg = NULL; T_PCB *ptSendPCB; T_PCB *ptRecvPCB; BYTE ucUrgent; BOOLEAN bResult = TRUE; WORD32 dwRcvMbx; WORD32 dwtimeout; ptMsg = (T_MSG *)pucMsgPtr; ptMsg->ptNextMsg = NULL; ptSendPCB = R_GetSelfPCBPtr(); ptRecvPCB = R_GetPCBPtrByPNO(ptMsg->tReceiver.wPno); if((NULL == ptRecvPCB) || (NO == ptRecvPCB->ucIsUse)) { free(ptMsg); return FALSE; } dwRcvMbx = M_atScheTCB[ptRecvPCB->wTno].dwMailBoxId; if (ptSendPCB && ptRecvPCB && (ptSendPCB->wTno == ptRecvPCB->wTno)) { /*本任务内PCB通信*/ DispatchMsg(ptMsg, ptRecvPCB->wTno); } else { /* 任务间通讯 */ ucUrgent = (COMM_ASYN_URGENT == ptMsg->ucMsgType || \ COMM_SYN_URGENT == ptMsg->ucMsgType) ? \ VOS_URGENT_MSG:VOS_NOT_URGENT_MSG; /* 将消息发送到相应调度任务的邮箱中 */ if(COMM_UNRELIABLE == dwParam) dwtimeout = NO_WAIT; else dwtimeout = WAIT_FOREVER; /*发送失败,删除消息*/ if (FALSE == Vos_AppendQueue(dwRcvMbx,(BYTE *)&ptMsg, sizeof(ptMsg), ucUrgent, dwtimeout)) { free(ptMsg); return FALSE; } } return bResult; }
bool_t NetworkTask::Run() { bool_t ret = FALSE; Node *root = static_cast< Node* >(Thread::UserPtr()); if(!root) { ECILA_TRACE(); return FALSE; } CacheNode(root); while(!Thread::IsStop()) { demultiplexer_->HandleEvents(0); ret = DispatchMsg(); if(!ret) { ecila_msleep(1); } } return TRUE; }
int R_SendMsgFromTask(WORD16 wMsgId,VOID *pData,WORD32 dwMsgLen,BYTE ucMsgType,PID *ptReceiver) { T_MSG *ptMsg = NULL; T_PCB* ptDestPCB = NULL; if(NULL == pData) dwMsgLen = 0; ptDestPCB = R_GetPCBPtrByPNO(ptReceiver->wPno); ptMsg = R_CreateMsg(dwMsgLen); /*填充T_MSG的基本信息*/ ptMsg->wMsgId = wMsgId; ptMsg->ucMsgType = ucMsgType; ptMsg->ucIsSave = COMM_NOT_SAVED; ptMsg->ptNextMsg = NULL; memcpy(&ptMsg->tReceiver,ptReceiver,sizeof(PID)); if (pData != NULL) memcpy((BYTE *)(ptMsg + 1), pData,dwMsgLen); /*将填充内容拷入消息体*/ if (M_atScheTCB[ptDestPCB->wTno].dwTaskId == GetCurTaskID() || M_atScheTCB[ptDestPCB->wTno].dwMailBoxId == VOS_CREATE_QUEUE_FAILURE) { DispatchMsg(ptMsg, ptDestPCB->wTno); } else { /*将消息指针放到进程所属调度任务的邮箱*/ if (TRUE != Vos_AppendQueue(M_atScheTCB[ptDestPCB->wTno].dwMailBoxId, (BYTE *)&ptMsg, sizeof(VOID *), VOS_NOT_URGENT_MSG, (WORD32)WAIT_FOREVER)) { printf("[%s:%d]\n send msg=%d fail,Recv=0x%x\n", __FUNCTION__, __LINE__,wMsgId,ptReceiver->wPno); return ERR_COMM_SEND_ASYN_MSG_FAILED; } } return SUCCESS; }
void CDuplicateBaseManager::OnRecvMsg(const SMessage *pMsg) { const SDuplicateMsg * prtMsg = static_cast<const SDuplicateMsg*>(pMsg); if (prtMsg == nullptr) { rfalse("副本消息转换失败"); return; } const SQDuplicateEarningClear* clearMsg = nullptr; switch (prtMsg->_protocol) { case SDuplicateMsg::REQUEST_ENTER_SPECIFY_TOLLGATE: ///请求挑战指定的副本关卡 AskToEnterTollgate(prtMsg); break; case SDuplicateMsg::REQUEST_EARNING_CLEAR: clearMsg = static_cast<const SQDuplicateEarningClear*>(pMsg); if (clearMsg != nullptr) EarningClearProcess(clearMsg->duplicateID, clearMsg->tollgateID, clearMsg->combatGrade); break; case SDuplicateMsg::REQUEST_START_CHALLENGE: OnStartToChallenge(); /// 记录战斗开始时间(由于子类有重载OnStartToChanllenge 故在此处记录 不管此次是否通过战斗申请 在结算前都应由此函数通知切换场景) _time64(&m_tBattleStartTime); break; case SDuplicateMsg::REREQUEST_TOLLGATE_DROPED_ITEM: ReRequestTollgateDropedItem(prtMsg); break; default: ///子类的差异化的消息处理模块 DispatchMsg(prtMsg); break; } }
void MessageForWindow::Dispatch() { DispatchMsg(this); }