Example #1
0
ret_ CNetworkHandle::OnMessage(const ub_1 *pMsg,
                               size_ nSize,
                               const TMsgInfo *pMsgInfo)
{
#ifdef _DEBUG_
    if (!pMsg)
        return PARAMETER_NULL | PARAMETER_1;

    if (0 == nSize)
        return PARAMETER_ERROR | PARAMETER_2;

    if (!pMsgInfo)
        return PARAMETER_NULL | PARAMETER_3;
#endif

    CNetworkConf *pConf = (CNetworkConf *)GetConf();

#ifdef _DEBUG_
    if (!pConf)
        return NO_ELEMENT_IN_CONTAINER;
#endif

    CPDUInfo *pPDUInfo = null_v;

    try
    {
        v_ CommandID((size_ *)(pMsg +
                               pConf->GetCommandID()->Offset(pMsg, nSize)));
        ret_ Ret = pConf->IdentifyID(CommandID, pPDUInfo, DIRECTION_IN);

        if (SUCCESS != Ret)
            return Ret;
    }
    catch (error_code err)
    {
        return err;
    }

    TMU tmu;

    tmu.pPDUInfo = pPDUInfo;
    tmu.pMessage = (ub_1 *)pMsg;
    tmu.nSize = nSize;
    tmu.pMsgInfo = (TMsgInfo *)pMsgInfo;

    CContainer *pContainer = CUIManager::Instance()->GetCurContainer();

    if (pContainer)
        pContainer->OnMessage(&tmu);

    return SUCCESS;
}