Exemplo n.º 1
0
    int CWorldDbmgr::Table2Insert(T_VECTOR_OBJECT* p, CDbOper& db)
    {
        if ( p->size() != 4 )
        {
            return -1;
        }

        uint16_t nBaseappId = VOBJECT_GET_U16((*p)[0]);
        TENTITYID eid = VOBJECT_GET_U32((*p)[1]);
        uint32_t nCbId = VOBJECT_GET_U32((*p)[2]);                      
        SEntityPropFromPluto* p2 = (SEntityPropFromPluto*)((*p)[3]->vv.p);

        const string& strEntityName = GetDefParser().GetTypeName(p2->etype);

        string strErr;
        uint64_t newid = db.InsertEntity(strEntityName, p2->data, strErr);
        if(newid == 0)
        {
            LogWarning("table_insert_err", "newid=0;err=%s", strErr.c_str());
            //cout << strErr << endl;
            //return -2;
        }

        //通知insert结果
        SyncRpcCall(g_pluto_sendlist, nBaseappId, MSGID_BASEAPP_TABLE2INSERT_RESP, eid, nCbId, newid, strErr);

        return 0;
    }
Exemplo n.º 2
0
    int CWorldMgrD::CreateCellInNewSpace(T_VECTOR_OBJECT* p)
    {
        if(p->size() != 4)
        {
            return -1;
        }

        CEntityMailbox& emb = VOBJECT_GET_EMB((*p)[0]);
        uint16_t etype = VOBJECT_GET_U16((*p)[1]);
#ifdef __USE_MSGPACK
        charArrayDummy *d = (charArrayDummy*)VOBJECT_GET_BLOB((*p)[2]);
#else
        const char* pszParams = VOBJECT_GET_STR((*p)[2]);
#endif
        charArrayDummy& props = *((charArrayDummy*)((*p)[3]->vv.p));

        uint16_t nCellappId = ChooseACellApp(etype);
        CMailBox* mb = GetServerMailbox(nCellappId);
        if(mb)
        {
#ifdef __USE_MSGPACK
            mb->RpcCall(GetRpcUtil(), MSGID_CELLAPP_CREATE_CELL_IN_NEW_SPACE, emb, etype, *d, props);
#else
            mb->RpcCall(GetRpcUtil(), MSGID_CELLAPP_CREATE_CELL_IN_NEW_SPACE, emb, etype, pszParams, props);
#endif
        }

        return 0;
    }
Exemplo n.º 3
0
int CWorldLogin::NotifyClientToAttach(T_VECTOR_OBJECT* p)
{
    if(p->size() != 3)
    {
        return -1;
    }

    const char* pszAccount = VOBJECT_GET_STR((*p)[0]);
    uint16_t baseapp_id = VOBJECT_GET_U16((*p)[1]);
    const char* pszKey = VOBJECT_GET_STR((*p)[2]);

    map<string, int>::const_iterator iter = m_accounts2fd.find(pszAccount);
    if(iter == m_accounts2fd.end())
    {
        LogWarning("NotifyClientToAttach", "Account '%s' hasn't client", pszAccount);
        return -2;
    }

    LogDebug("NotifyClientToAttach", "account=%s;fd=%d", pszAccount, iter->second);
    CMailBox* mb = GetServer()->GetClientMailbox(iter->second);
    if(mb != NULL)
    {
        CMailBox* smb = GetServer()->GetServerMailbox(baseapp_id);
        if(smb == NULL)
        {
            LogWarning("NotifyClientToAttach", "error baseapp_id:%d", baseapp_id);
            return -3;
        }

        mb->RpcCall(GetRpcUtil(), MSGID_CLIENT_NOTIFY_ATTACH_BASEAPP, smb->GetServerName().c_str(), smb->GetServerPort(), pszKey);
    }

    return 0;
}
Exemplo n.º 4
0
    int CWorldDbmgr::SelectAccount(T_VECTOR_OBJECT* p, CDbOper& db)
    {
#if __PLAT_PLUG_IN || __PLAT_PLUG_IN_NEW
		if(p->size() != 3)
#else
		if(p->size() != 4)
#endif
        {
            return -1;
        }

        uint16_t nServerId = VOBJECT_GET_U16((*p)[0]);
        int32_t nFd = VOBJECT_GET_I32((*p)[1]);
        const char* s1 = VOBJECT_GET_STR((*p)[2]);
#if __PLAT_PLUG_IN || __PLAT_PLUG_IN_NEW

#else
        const char* s2 = VOBJECT_GET_STR((*p)[3]);
#endif

        CPluto* u = new CPluto;
        string strErr;
#if __PLAT_PLUG_IN || __PLAT_PLUG_IN_NEW
		if(db.SelectAccount(nFd, s1, *u, strErr) != 0)
#else
        if(db.SelectAccount(nFd, s1, s2, *u, strErr) != 0)
#endif
        {
            delete u;
            //cout << strErr << endl;
            LogWarning("SelectAccount_err", "%s", strErr.c_str());
            return -2;
        }

        //通知db结果
        CEpollServer* s = this->GetServer();
        CMailBox* mb = s->GetServerMailbox(nServerId);
        if(mb)
        {
#ifdef _WIN32
            mb->RpcCall(*u);
#else
            u->SetMailbox(mb);

            LogDebug("CWorldDbmgr::SelectAccount", "u.GenLen()=%d", u->GetLen());

            g_pluto_sendlist.PushPluto(u);
#endif
        }
        else
        {
            delete u;
            LogWarning("SelectAccount_err", "no mb!");
            return -3;
        }

        return 0;
    }
Exemplo n.º 5
0
    int CWorldMgrD::CreateBaseFromDbByName(T_VECTOR_OBJECT* p)
    {
        if(p->size() < 3)
        {
            return -1;
        }

        uint8_t createFlag = VOBJECT_GET_U8((*p)[0]);
        const char* pszEntityType = VOBJECT_GET_STR((*p)[1]);
        const char* pszKey = VOBJECT_GET_STR((*p)[2]);

        uint16_t nBaseappId;
        if(p->size() > 3)
        {
            //指定了baseapp
            nBaseappId = VOBJECT_GET_U16((*p)[3]);
        }
        else
        {
            //未指定baseapp,选择一个
            nBaseappId = ChooseABaseApp(pszEntityType);
        }

#ifdef __TEST_LOGIN
        CEpollServer* s = this->GetServer();
        CMailBox* mb = s->GetServerMailbox(nBaseappId);

        if (mb)
        {
            TENTITYID nOtherEntityId = 0;

            CPluto* u = new CPluto;
            (*u).Encode(MSGID_BASEAPP_LOOKUP_ENTITY_CALLBACK);
            (*u) << (uint64_t)0 << this->GetNextEntityId()<< createFlag << pszKey << nOtherEntityId;
            (*u) << this->GetDefParser().GetTypeId(pszEntityType);

            TDBID dbid2 = 0;

            (*u).ReplaceField(PLUTO_FILED_BEGIN_POS, dbid2);
            (*u) << EndPluto;

            u->SetMailbox(mb);

            LogDebug("CWorldMgrD::CreateBaseFromDbByName", "u.GenLen()=%d", u.GetLen());

            mb->PushPluto(u);
        }

#else
        CMailBox* mb = GetServerMailbox(SERVER_DBMGR);
        if(mb)
        {
            mb->RpcCall(GetRpcUtil(), MSGID_DBMGR_CREATEBASE_FROM_NAME, nBaseappId, createFlag, pszEntityType, pszKey);
        }
#endif
        return 0;
    }
Exemplo n.º 6
0
//发到cell的entity rpc调用
T_VECTOR_OBJECT* CRpcUtil::DecodeCellEntityRpc(CPluto& u)
{
    //特殊处理
    T_VECTOR_OBJECT* ll = new T_VECTOR_OBJECT;

    VOBJECT* v = new VOBJECT;
    u.FillVObject(V_ENTITYMB, *v);
    ll->push_back(v);
    if(u.GetDecodeErrIdx() > 0)
    {
        return ll;
    }
    CEntityMailbox& mb = VOBJECT_GET_EMB(v);

    //取funcid
    v = new VOBJECT;
    u.FillVObject(V_UINT16, *v);
    ll->push_back(v);
    if(u.GetDecodeErrIdx() > 0)
    {
        return ll;
    }
    int32_t nFuncId = (int32_t)VOBJECT_GET_U16(v);

    const SEntityDef* pDef = GetWorld()->GetDefParser().GetEntityDefByType(mb.m_nEntityType);
    if(pDef)
    {
        const string& strFunc = pDef->m_cellMethodsMap.GetStrByInt(nFuncId);
        map<string, _SEntityDefMethods*>::const_iterator iter11 = pDef->m_cellMethods.find(strFunc);
        if(iter11 != pDef->m_cellMethods.end())
        {
            _SEntityDefMethods* pMethods = iter11->second;
            list<VTYPE>& refs = pMethods->m_argsType;
            list<VTYPE>::const_iterator iter2 = refs.begin();
            for(; iter2 != refs.end(); ++iter2)
            {
                VOBJECT* v = new VOBJECT;
                u.FillVObject(*iter2, *v);
                ll->push_back(v);

                if(u.GetDecodeErrIdx() > 0)
                {
                    break;
                }
            }
            return ll;
        }
    }

    ClearTListObject(ll);
    return NULL;
}
Exemplo n.º 7
0
    int CWorldDbmgr::UpdateArrayItemsToDb(T_VECTOR_OBJECT* p, CDbOper& db)
    {
        if( p->size() != 5 )
        {
            return -1;
        }
        const string & itemName = VOBJECT_GET_SSTR((*p)[0]);
        const TDBID dbid = VOBJECT_GET_U64((*p)[1]);
        const uint16_t nBaseappId = VOBJECT_GET_U16((*p)[2]);
        const int32_t ref = VOBJECT_GET_I32((*p)[3]);
        const string& itemsData = VOBJECT_GET_SSTR((*p)[4]);
        //uint32_t l = itemsData.size();

        //LogError("UpdateArrayItemsToDb", "[itemName = %s] [dbid = %d] [nBaseappId = %d] [ref = %d] [itemsData = %d]", 
        //        itemName.c_str(), dbid, nBaseappId, ref, itemsData.size());
        //cout<<itemsData.c_str()<<endl;
        //cout<<itemsData.size()<<endl;
        CPluto* u = new CPluto();
        u->FillBuff(itemsData.c_str(), itemsData.size());
        u->SetMaxLen(u->GetLen());
        string strErr;
        
        //cout<<"world update"<<endl;
        if( !db.UpdateArrayToDb(itemName, dbid, *u, nBaseappId, ref, strErr) )
        {
            LogError("UpdateArrayToDb failure", "[error = %s] [status = %d]", strErr.c_str(), -1);
            CPluto* u1 = new CPluto;
            u1->Encode(MSGID_BASEAPP_UPDATE_ITEMS_CALLBACK);
            *u1 << ref << (uint16_t)1 << strErr<< EndPluto;
            CMailBox* mb = GetServerMailbox(nBaseappId);
            if(mb)
            {
                //cout<<"send pluto"<<endl;
                u1->SetMailbox(mb);

                //LogDebug("CWorldDbmgr::UpdateArrayItemsToDb", "u1.GenLen()=%d", u1->GetLen());

                g_pluto_sendlist.PushPluto(u1);
            }
            else
            {
                delete u1;
                LogWarning("CWorldDbmgr::UpdateArrayItemsToDb", "");
            }
        }

        delete u;

        //cout<<"do success update"<<endl;
        return 0;

    }
Exemplo n.º 8
0
	int CWorldDbmgr::TableExcute(T_VECTOR_OBJECT* p, CDbOper& db)
	{
		if (p->size() != 3)
		{
			LogError("CWorldDbmgr::TableInsert", "p->size()=%d", p->size());
			return -1;
		}

		uint16_t nBaseappId = VOBJECT_GET_U16((*p)[0]);
		const string& strSql = VOBJECT_GET_SSTR((*p)[1]);
		uint32_t ref = VOBJECT_GET_U32((*p)[2]);

		//LogDebug("CWorldDbmgr::TableExcute", "nBaseappId=%d;ref=%d;strSql=%s",
		//	nBaseappId, ref,  strSql.c_str());

		string strErr;
		uint8_t ret = db.TableExcute(strSql, strErr);

		if(ret != 0)
		{
			LogWarning("ExcuteDB_err", "ret=%d;err=%s", ret, strErr.c_str());
		}
		//ref == 0 无返回
		if (ref == 0)
		{
			return 0;
		}
		
		//通知db结果
		CEpollServer* s = this->GetServer();
		CMailBox* mb = s->GetServerMailbox(nBaseappId);
		if(mb)
		{
#ifdef _WIN32
			mb->RpcCall(GetRpcUtil(), MSGID_BASEAPP_TABLE_EXCUTE_CALLBACK, ref, ret );
#else
			CRpcUtil& rpc = GetRpcUtil();
			CPluto* u = new CPluto;
			rpc.Encode(*u, MSGID_BASEAPP_TABLE_EXCUTE_CALLBACK, ref, ret);
			u->SetMailbox(mb);

			LogDebug("CDbOper::InsertDB", "u.GenLen()=%d", u->GetLen());

			g_pluto_sendlist.PushPluto(u);
#endif
		}
		return 0;
	}
Exemplo n.º 9
0
	int CWorldDbmgr::TableUpdateBatch(T_VECTOR_OBJECT* p, CDbOper& db)
	{
		LogDebug("CWorldDbmgr::TableUpdateBatch", "");
		if( p->size() != 5 )
		{
			return -1;
		}
		const string & itemName = VOBJECT_GET_SSTR((*p)[0]);
		const string & uniqKey = VOBJECT_GET_SSTR((*p)[1]);
		const uint16_t nBaseappId = VOBJECT_GET_U16((*p)[2]);
		const int32_t ref = VOBJECT_GET_I32((*p)[3]);
		const string& itemsData = VOBJECT_GET_SSTR((*p)[4]);

		//cout<<itemsData.c_str()<<endl;
		//cout<<itemsData.size()<<endl;
		CPluto* u = new CPluto();
		u->FillBuff(itemsData.c_str(), itemsData.size());
		u->SetMaxLen(u->GetLen());
		string strErr;
		int ret = db.UpdateBatch(itemName, uniqKey, *u, nBaseappId, ref, strErr);
		//cout<<"world update"<<endl;
		if( 0 == ret)
		{
			delete u;
            return 0;
		}
		LogError("UpdateArrayToDb failure", "[error = %s] [ret = %d]", strErr.c_str(), ret);
		delete u;
		CPluto* u1 = new CPluto;
		u1->Encode(MSGID_BASEAPP_TABLE_UPDATE_BATCH_CB);
		*u1 << ref << (uint16_t)ret << EndPluto;
		CMailBox* mb = GetServerMailbox(nBaseappId);
		if(mb)
		{
			//cout<<"send pluto"<<endl;
			u1->SetMailbox(mb);

			//LogDebug("CWorldDbmgr::UpdateArrayItemsToDb", "u1.GenLen()=%d", u1->GetLen());

			g_pluto_sendlist.PushPluto(u1);
		}
        else
        {
            delete u1;
            LogWarning("CWorldDbmgr::UpdateArrayItemsToDb", "");
        }
		return -11;
	}
Exemplo n.º 10
0
    int CWorldDbmgr::Table2Excute(T_VECTOR_OBJECT* p, CDbOper& db)
    {
        if ( p->size() != 4 )
        {
            return -1;
        }

        uint16_t nBaseappId = VOBJECT_GET_U16((*p)[0]);
        TENTITYID eid = VOBJECT_GET_U32((*p)[1]);
        uint32_t nCbId = VOBJECT_GET_U32((*p)[2]);               
        const string& strSql = VOBJECT_GET_SSTR((*p)[3]);

        string strErr;
        int8_t nRet = (int8_t)db.Table2Excute(strSql, strErr);

        SyncRpcCall(g_pluto_sendlist, nBaseappId, MSGID_BASEAPP_TABLE2EXCUTE_RESP, eid, nCbId, nRet, strErr);

        return 0;
    }
Exemplo n.º 11
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;
    }
Exemplo n.º 12
0
    int CWorldDbmgr::TableSelect(T_VECTOR_OBJECT* p, CDbOper& db)
    {
        if (p->size() != 5)
        {
            LogError("CWorldDbmgr::TableSelect", "p->size()=%d", p->size());
            return -1;
        }

        uint16_t nBaseappId = VOBJECT_GET_U16((*p)[0]);
        uint32_t entityId = VOBJECT_GET_U32((*p)[1]);
        const string& strCallBackFunc = VOBJECT_GET_SSTR((*p)[2]);
        const string& strEntityType = VOBJECT_GET_SSTR((*p)[3]);
        const string& strSql = VOBJECT_GET_SSTR((*p)[4]);

        //LogDebug("CWorldDbmgr::TableSelect", "nBaseappId=%d;entityId=%d;strCallBackFunc=%s;strEntityType=%s;strSql=%s",
        //                                      nBaseappId, entityId, strCallBackFunc.c_str(), strEntityType.c_str(), strSql.c_str());

        db.TableSelect(nBaseappId, entityId, strCallBackFunc, strEntityType, strSql);

        return 0;
    }
Exemplo n.º 13
0
    int CWorldDbmgr::Table2Select(T_VECTOR_OBJECT* p, CDbOper& db)
    {
        if ( p->size() != 5 )
        {
            return -1;
        }

        uint16_t nBaseappId = VOBJECT_GET_U16((*p)[0]);
        TENTITYID eid = VOBJECT_GET_U32((*p)[1]);
        uint32_t nCbId = VOBJECT_GET_U32((*p)[2]);    
        const string& strEntity = VOBJECT_GET_SSTR((*p)[3]);
        const string& strSql = VOBJECT_GET_SSTR((*p)[4]);

        string strErr;
        int nRet = db.Table2Select(nBaseappId, eid, nCbId, strEntity, strSql, strErr);
        if(nRet != 0)
        {
            LogWarning("CWorldDbmgr::Table2Select.err", "ret=%d;err=%s", nRet, strErr.c_str());
        }

        return 0;
    }
Exemplo n.º 14
0
    int CWorldDbmgr::LoadEntitiesOfType(T_VECTOR_OBJECT* p, CDbOper& db)
    {
        if(p->size() != 2)
        {
            return -1;
        }

        const char* pszEntityType = VOBJECT_GET_STR((*p)[0]);
        uint16_t nBaseappId = VOBJECT_GET_U16((*p)[1]);
        string strErr;
        int nRet = db.LoadAllEntitiesOfType(pszEntityType, nBaseappId, strErr);
        if(nRet != 0)
        {
            //load数据失败,退出进程
            //todo,置全局退出标记
            LogCritical("dbmgr.LoadEntitiesOfType", "err=%d", nRet);
            exit(-1);
            return -1;
        }

        return 0;
    }
Exemplo n.º 15
0
    int CWorldDbmgr::LoadingArrayItemsToInventory(T_VECTOR_OBJECT* p, CDbOper& db)
    {
        if( p->size() != 4 )
        {
            return -1;
        }
        const string & itemName = VOBJECT_GET_SSTR((*p)[0]);
        //cout<<itemName.c_str()<<endl;
        const TDBID dbid = VOBJECT_GET_U64((*p)[1]);
        uint16_t nBaseappId = VOBJECT_GET_U16((*p)[2]);
        const int32_t ref = VOBJECT_GET_I32((*p)[3]);

        string strErr;
        if( !db.LoadingItemsToInventory(itemName, dbid, nBaseappId, ref, strErr) )
        {
            CPluto* u1 = new CPluto;
            u1->Encode(MSGID_BASEAPP_ITEMS_LOADING_CALLBACK);
            *u1 << ref <<(uint16_t)1 << itemName << strErr<< EndPluto;
            CMailBox* mb = GetServerMailbox(nBaseappId);
            if(mb)
            {
                //cout<<"send pluto"<<endl;
                u1->SetMailbox(mb);

                LogDebug("CWorldDbmgr::UpdateArrayItemsToDb", "u1.GenLen()=%d", u1->GetLen());

                g_pluto_sendlist.PushPluto(u1);
            }
            else
            {
                delete u1;
                LogWarning("CWorldDbmgr::UpdateArrayItemsToDb", "");
            }
        }
        return 0;
    }
Exemplo n.º 16
0
    int CWorldDbmgr::IncremantalUpdateItems(T_VECTOR_OBJECT* p, CDbOper& db)
    {

        if ( p->size() != 5 )
        {
            LogError("CWorldDbmgr::IncremantalUpdateItems", "p->size()=%d", p->size());
            return -1;
        }

        const string & tblName = VOBJECT_GET_SSTR((*p)[0]);
        const string & optName = VOBJECT_GET_SSTR((*p)[1]);
        const uint16_t nBaseappId = VOBJECT_GET_U16((*p)[2]);
        const int32_t  ref = VOBJECT_GET_I32((*p)[3]);
        const string& itemsData = VOBJECT_GET_SSTR((*p)[4]);

        LogDebug("CWorldDbmgr::IncremantalUpdateItems", "tblName=%s;optName=%s;nBaseappId=%d;ref=%d",
            tblName.c_str(), optName.c_str(), nBaseappId, ref);

        CPluto* u = new CPluto();
        u->FillBuff(itemsData.c_str(), itemsData.size());
        u->SetMaxLen(u->GetLen());

        string strErr;
        uint8_t ret = -1;
        if ( optName.compare("update") == 0 )
        {

            ret = db.IncrementalUpdateItems(tblName, nBaseappId, *u, ref, strErr);
            if( ret != 0 )
            {
                CPluto* u1 = new CPluto;
                u1->Encode(MSGID_BASEAPP_UPDATE_ITEMS_CALLBACK);
                *u1 << ref << (uint16_t)1 << strErr<< EndPluto;
                CMailBox* mb = GetServerMailbox(nBaseappId);
                if(mb)
                {
                    u1->SetMailbox(mb);
                    //LogDebug("CWorldDbmgr::IncremantalUpdateItems", "u1.GenLen()=%d", u1->GetLen());
                    g_pluto_sendlist.PushPluto(u1);
                }
                else
                {
                    delete u1;
                    u1 = NULL;
                    LogWarning("CWorldDbmgr::IncremantalUpdateItems", "");
                }
            }
            delete u;
            u = NULL;
            return 0;
        }
        else if( optName.compare("insert") == 0 )
        {

            ret = db.IncremantalInsertItems(tblName, nBaseappId, *u, ref, strErr);
            if( ret != 0 )
            {
                CPluto* u1 = new CPluto;
                u1->Encode(MSGID_BASEAPP_INSERT_ITEMS_CALLBACK);
                *u1 << ref << (uint16_t)1 << strErr<< EndPluto;
                CMailBox* mb = GetServerMailbox(nBaseappId);
                if(mb)
                {
                    u1->SetMailbox(mb);
                    //LogDebug("CWorldDbmgr::IncremantalInsertItems", "u1.GenLen()=%d", u1->GetLen());
                    g_pluto_sendlist.PushPluto(u1);
                }
                else
                {
                    delete u1;
                    u1 = NULL;
                    LogWarning("CWorldDbmgr::IncremantalInsertItems", "");
                }
            }
            delete u;
            u = NULL;
            return 0;
        }
        
    }
Exemplo n.º 17
0
    int CWorldDbmgr::LookupEntityByName(T_VECTOR_OBJECT* p, CDbOper& db)
    {
        if(p->size() != 4)
        {
            return -1;
        }

        uint16_t nBaseappId = VOBJECT_GET_U16((*p)[0]);
        uint8_t nCreateFlag = VOBJECT_GET_U8((*p)[1]);
        const char* pszEntityName = VOBJECT_GET_STR((*p)[2]);
        const char* pszKey = VOBJECT_GET_STR((*p)[3]);

        const string& strKey(pszKey);
        //先查找该key相关的entity是否已经创建出来了
        SEntityLookup* pLookup = LookupEntityInfo(strKey, pszEntityName);
        if(pLookup != NULL)
        {
            //LogInfo("CWorldDbmgr::LookEntityByName", "entity exists;key=%s;eid=%d;baseapp=%d", \
            //        pszKey, pLookup->eid, pLookup->sid);

            CMailBox* mb = GetServerMailbox(pLookup->sid);
            if(mb)
            {
                CPluto* u = new CPluto;
                u->Encode(MSGID_BASEAPP_ENTITY_MULTILOGIN);
                (*u) << pLookup->eid << EndPluto;
                u->SetMailbox(mb);

                //LogDebug("CWorldDbmgr::LookupEntityByName", "u.GenLen()=%d", u->GetLen());

                g_pluto_sendlist.PushPluto(u);
            }

            return 0;
        }

        TENTITYID new_eid = MyGetNextEntityId();
        CPluto* u = new CPluto;
        string strErr;
        if(db.LookupEntityByName(nCreateFlag, pszEntityName, strKey, new_eid, *u, nBaseappId, strErr) != 0)
        {
            delete u;
            //cout << strErr << endl;
            LogWarning("LookEntityByName_err", "%s", strErr.c_str());
            return -2;
        }

        //add for lookup
        CreateNewEntityToLookup(strKey, pszEntityName, new_eid, nBaseappId);

        //通知db结果
        CEpollServer* s = this->GetServer();
        CMailBox* mb = s->GetServerMailbox(nBaseappId);
        if(mb)
        {
#ifdef _WIN32
            mb->RpcCall(*u);
#else
            u->SetMailbox(mb);

            LogDebug("CWorldDbmgr::LookupEntityByName", "u.GenLen()=%d", u->GetLen());

            g_pluto_sendlist.PushPluto(u);
#endif
        }
        else
        {
            LogWarning("CWorldDbmgr::LookupEntityByName", "u.GenLen()=%d", u->GetLen());
            delete u;
        }

        return 0;
    }