Example #1
0
    int CWorldMgrD::init(const char* pszEtcFile)
    {
        LogInfo("CWorldMgrD::init()", "");

        int nWorldInit = world::init(pszEtcFile);
        if(nWorldInit != 0)
        {
            return nWorldInit;
        }

        //将所有的
        list<CMailBox*>& mbs = m_mbMgr.GetMailboxs();
        list<CMailBox*>::iterator iter = mbs.begin();
        for(; iter != mbs.end(); ++iter)
        {
            CMailBox* p = *iter;
            if(p->GetServerMbType() == SERVER_BASEAPP)
            {
                m_baseBalance.AddNewId(p->GetMailboxId());
            }
            else if(p->GetServerMbType() == SERVER_CELLAPP)
            {
                m_cellBalance.AddNewId(p->GetMailboxId());
            }
        }

        return 0;
    }
Example #2
0
bool CWorldCrossclient::CcCheckClientRpc(CPluto& u)
{
    CMailBox* mb = u.GetMailbox();
    if(mb && mb->GetMailboxId() == EXTERN_MAILBOX_ID)
    {
        //如果消息来自跨服连接
        return true;
    }

    return CheckClientRpc(u);
}
Example #3
0
    int CWorldDbmgr::init(const char* pszEtcFile)
    {
        LogDebug("CWorldDbmgr::init()", "a=%d", 1);

        int nWorldInit = world::init(pszEtcFile);
        if(nWorldInit != 0)
        {
            return nWorldInit;
        }

        try
        {
            GetDefParser().init(m_cfg->GetValue("init", "def_path").c_str());
            GetDefParser().ReadDbCfg(m_cfg);
        }
        catch(const CException& e)
        {
            LogDebug("CWorldDbmgr::init().error", "%s", e.GetMsg().c_str());
            return -1;
        }

        ////需要一个空的lua环境来保存LUA_TABLE类型的数据
        /*
        m_L = lua_open();
        if(m_L==NULL)
        {
          return -1;
        }
        luaL_newmetatable(m_L, "G_LUATABLES");
        lua_setglobal(m_L, "G_LUATABLES");
        */
        //将所有的
        list<CMailBox*>& mbs = m_mbMgr.GetMailboxs();
        list<CMailBox*>::iterator iter = mbs.begin();
        for(; iter != mbs.end(); ++iter)
        {
            CMailBox* p = *iter;
            if(p->GetServerMbType() == SERVER_BASEAPP)
            {
                m_baseBalance.AddNewId(p->GetMailboxId());
            }
            //else if(p->GetServerMbType() == SERVER_CELLAPP)
            //{
            //  m_cellBalance.addNewId(p->GetMailboxId());
            //}
        }

        return 0;
    }
Example #4
0
//根据server_id获取服务器绑定端口
uint16_t world::GetServerPort(uint16_t sid)
{
    list<CMailBox*>& mbs = m_mbMgr.GetMailboxs();
    list<CMailBox*>::iterator iter = mbs.begin();
    for(; iter != mbs.end(); ++iter)
    {
        CMailBox* pmb = *iter;
        if(pmb->GetMailboxId() == sid)
        {
            return pmb->GetServerPort();
        }
    }

    return 0;
}
Example #5
0
    //其他服务器进程退出后的回调方法
    int CWorldMgrD::OnServerShutdown(T_VECTOR_OBJECT* p)
    {
        if(p->size() != 1)
        {
            return -1;
        }

        //标记这个进程已经退出
        uint16_t nServerId = VOBJECT_GET_U16((*p)[0]);
        m_setShutdown.set(nServerId);

        LogDebug("CWorldMgrD::OnServerShutdown", "nServerId=%d", nServerId);

        //检查是否除dbmgr之外的进程都已经退出
        bool bQuitAll = true;
        vector<CMailBox*>& mbs = GetServer()->GetAllServerMbs();
        vector<CMailBox*>::iterator iter = mbs.begin();
        for(; iter != mbs.end(); ++iter)
        {
            CMailBox* basemb = *iter;
            if(basemb && basemb->GetServerMbType() != SERVER_DBMGR)
            {
                if(!m_setShutdown.test(basemb->GetMailboxId()))
                {
                    bQuitAll = false;
                    break;
                }
            }
        }

        if(bQuitAll)
        {
            //通知dbmgr退出
            RpcCall(SERVER_DBMGR, MSGID_DBMGR_SHUTDOWN_SERVER, (uint8_t)1);

            //cwmd退出
            GetServer()->Shutdown();
        }

        return 0;
    }
Example #6
0
int CWorldCrossserver::init(const char* pszEtcFile)
{
	LogInfo("CWorldCrossserver::init()", "");

	int nWorldInit = world::init(pszEtcFile);
	if(nWorldInit != 0)
	{
		return nWorldInit;
	}

	//将所有的
	list<CMailBox*>& mbs = m_mbMgr.GetMailboxs();
	list<CMailBox*>::iterator iter = mbs.begin();
	for(; iter != mbs.end(); ++iter)
	{
		CMailBox* p = *iter;
		if(p->GetServerMbType() == SERVER_BASEAPP)
		{
			m_baseBalance.AddNewId(p->GetMailboxId());
		}
	}

	//计算def文件的md5
	{
		try
		{
			const string& strDefPath = GetCfgReader()->GetValue("init", "def_path");
			m_strDefMd5.assign(GetDefParser().CalcMd5OfAll(strDefPath.c_str()));
			LogInfo("CalcMd5OfAll", "md5=%s", m_strDefMd5.c_str());
		}
		catch(const CException& ex)
		{
			LogError("CWorldCrossserver::init.error", "Failed_to_calc_def_md5");
			return -10;
		}        
	}    

	return 0;
}