Beispiel #1
0
///notice send msg
void CwxAppFramework::innerNoticeSendMsgByConn(CwxAppFramework* pApp,
                                               CwxAppNotice* pNotice)
{
    CwxMsgBlock* msg = (CwxMsgBlock*)pNotice->m_noticeArg;
    CwxAppHandler4Msg* pConn = (CwxAppHandler4Msg*)pApp->m_pReactor->getHandlerByConnId(msg->send_ctrl().getConnId());
    if (!pConn || 
        (CwxAppConnInfo::ESTABLISHED != pConn->getConnInfo().getState()))
    {
        if (msg->send_ctrl().isFailNotice())
        {
            pApp->onFailSendMsg(msg);
        }
        if (msg) CwxMsgBlockAlloc::free(msg);
        pNotice->m_noticeArg = NULL;
        return;
    }
    if (!msg->send_ctrl().isUndoConn())
    {
        int ret = 0;
        if (msg->send_ctrl().isResumeConn())
        {
            ret = pConn->reactor()->resumeHandler(pConn, CwxAppHandler4Base::READ_MASK);
            if (0 != ret)
            {
                CWX_ERROR(("Failure to resume handler, conn_id=[%u]", msg->send_ctrl().getConnId()));
                pConn->close();
            }
        }
        else if (msg->send_ctrl().isSuspendConn())
        {
            ret = pConn->reactor()->suspendHandler(pConn, CwxAppHandler4Base::READ_MASK);
            if (0 != ret)
            {
                CWX_ERROR(("Failure to resume handler, conn_id=[%u]", msg->send_ctrl().getConnId()));
                pConn->close();
            }
        }
    }
    if (!pConn->putMsg(msg))
    {
        if (msg->send_ctrl().isFailNotice())
        {
            pApp->onFailSendMsg(msg);
        }
        if (msg) CwxMsgBlockAlloc::free(msg);
        pNotice->m_noticeArg = NULL;
    }
}
Beispiel #2
0
///notice noticeReconnect 
void CwxAppFramework::innerNoticeReconnect(CwxAppFramework* pApp, CwxAppNotice* pNotice)
{
    CWX_UINT32 uiConnId = (CWX_UINT32)((size_t)(pNotice->m_noticeArg));
    CWX_UINT32 uiDelay = (CWX_UINT32)((size_t)(pNotice->m_noticeArg1));
    CwxAppHandler4Msg * pConn = (CwxAppHandler4Msg*)pApp->m_pReactor->getHandlerByConnId(uiConnId);
    if (!pConn)
    {
        CWX_ERROR(("Execute closing connect by conn_id[%u], it doesn't exist", uiConnId));
        return ;
    }
    if (!pConn->getConnInfo().isActiveConn())
    {
        CWX_ERROR(("Execute closing connect by conn_id[%u], it's not active conn", uiConnId));
        return ;
    }
    if (CwxAppConnInfo::CONNECTING == pConn->getConnInfo().getState())
    {
        CWX_DEBUG(("Conn[%s] is waiting connect, don't reconnect"));
        return;
    }
    pConn->getConnInfo().setActiveClose(false);
    pConn->getConnInfo().setReconn(true);
    pConn->getConnInfo().setReconnDelay(uiDelay);
    pConn->close();
}
Beispiel #3
0
///notice close connect
void CwxAppFramework::innerNoticeCloseConnect(CwxAppFramework* pApp, CwxAppNotice* pNotice)
{
    CWX_UINT32 uiConnId = (CWX_UINT32)((size_t)(pNotice->m_noticeArg));
    CwxAppHandler4Msg* pConn = (CwxAppHandler4Msg*)pApp->m_pReactor->getHandlerByConnId(uiConnId);
    if (!pConn)
    {
        CWX_ERROR(("Execute closing connect by conn_id[%u], it doesn't exist", uiConnId));
        return ;
    }
    pConn->getConnInfo().setActiveClose(true);
    pConn->close();
}