示例#1
0
    void CEntityBase::UnpickleCellDataFromPluto(CPluto& u)
    {
        //return NULL;
        const SEntityDef *pSEntityDef = this->GetEntityDef();

        if (pSEntityDef)
        {
            while(!u.IsEnd())
            {
                uint16_t nPropId;
                u >> nPropId;
                if(u.GetDecodeErrIdx() > 0)
                {
                    return;
                }

                //LogDebug("CEntityBase::UnpickleCellDataFromPluto", "nPropId=%d", nPropId);

                const string& strPropName = pSEntityDef->m_propertiesMap.GetStrByInt(nPropId);
                map<string, _SEntityDefProperties*>::const_iterator iter = pSEntityDef->m_properties.find(strPropName);
                if(iter == pSEntityDef->m_properties.end())
                {
                    return;
                }

                _SEntityDefProperties* p = iter->second;
                //if(IsCellFlag(p->m_nFlags))
                //{

                VOBJECT *v = new VOBJECT;

                u.FillVObject(p->m_nType, *v);

                if(u.GetDecodeErrIdx() > 0)
                {
                    delete v;
                    return;
                }

                this->m_cellData.insert(make_pair(iter->first, v));

                LogDebug("CEntityBase::UnpickleCellDataFromPluto", "nPropId=%d;strPropName=%s", nPropId, strPropName.c_str());

                    //lua_pushstring(m_L, strPropName.c_str());
                    //PushVObjectToLua(m_L, v);
                    //lua_rawset(m_L, -3);
                //}
            }

            return;
        }
        return;
    }
示例#2
0
//注册一个跨服服务提供者
int CWorldCrossserver::RegisterServer(CPluto& u)
{
	//globalbase名字
	CHECK_AND_GET_RPC_FIELD(u, strName, string);

	CEntityMailbox* emb = new CEntityMailbox;
	u >> *emb;
	if(u.GetDecodeErrIdx() > 0)
	{
		delete emb;
		return ERR_RPC_DECODE;
	}

	map<string, CEntityMailbox*>::iterator iter1 = m_globalBases.lower_bound(strName);
	if(iter1 != m_globalBases.end() && iter1->first == strName)
	{
		delete iter1->second;
		iter1->second = emb;
		LogInfo("CWorldCrossserver::RegisterServer", "s=%s;err=dup", strName.c_str());
	}
	else
	{
		m_globalBases.insert(iter1, make_pair(strName, emb));
		LogInfo("CWorldCrossserver::RegisterServer", "s=%s", strName.c_str());
	}

	return 0;
}
示例#3
0
    int CTimerdWorld::FromRpcCall(CPluto& u)
    {
        pluto_msgid_t msg_id = u.GetMsgId();
        if(!CheckClientRpc(u))
        {
            LogWarning("from_rpc_call", "invalid rpcall error.unknown msgid:%d\n", msg_id);
            return -1;
        }

        T_VECTOR_OBJECT* p = m_rpc.Decode(u);
        if(p == NULL)
        {
            LogWarning("from_rpc_call", "rpc decode error.unknown msgid:%d\n", msg_id);
            return -1;
        }
        if(u.GetDecodeErrIdx() > 0)
        {
            ClearTListObject(p);
            LogWarning("from_rpc_call", "rpc decode error.msgid:%d;pluto err idx=%d\n", msg_id, u.GetDecodeErrIdx());
            return -2;
        }

        int nRet = -1;
        switch(msg_id)
        {
            case MSGID_ALLAPP_SHUTDOWN_SERVER:
            {
                nRet = ShutdownServer(p);
                break;
            }
            default:
            {
                LogWarning("from_rpc_call", "unknown msgid:%d\n", msg_id);
            }
        }

        if(nRet != 0)
        {
            LogWarning("from_rpc_call", "rpc error.msg_id=%d;ret=%d\n", msg_id, nRet);
        }

        ClearTListObject(p);

        return 0;
    }
示例#4
0
    int CWorldDbmgr::FromRpcCall(CPluto& u, CDbOper& db)
    {
        //printf("CWorldDbmgr::from_rpc_call\n");
        //print_hex_pluto(u);

        pluto_msgid_t msg_id = -1;
        T_VECTOR_OBJECT* p = NULL;

        //这一段要加锁(2012/02/15改为不加锁)
        {
            //CMutexGuard _g(m_rpcMutex);

            msg_id = u.GetMsgId();
            if(!CheckClientRpc(u))
            {
                LogWarning("from_rpc_call", "invalid rpcall error.unknown msgid:%d\n", msg_id);
                return -1;
            }

            p = m_rpc.Decode(u);
            if(p == NULL)
            {
                LogWarning("from_rpc_call", "rpc Decode error.unknown msgid:%d\n", msg_id);
                return -1;
            }

            if(u.GetDecodeErrIdx() > 0)
            {
                ClearTListObject(p);
                //PrintHexPluto(u);
                LogWarning("from_rpc_call", "rpc Decode error.msgid:%d;pluto err idx=%d\n", msg_id, u.GetDecodeErrIdx());
                return -2;
            }
        }

        //这一段不用加锁
        int nRet = -1;
        switch(msg_id)
        {
            case MSGID_DBMGR_INSERT_ENTITY:
            {
                nRet = InsertDB(p, db);
                break;
            }
            case MSGID_DBMGR_SELECT_ENTITY:
            {
                nRet = LookupEntityByDbId(p, db);
                break;
            }
            case MSGID_DBMGR_UPDATE_ENTITY:
            {
                nRet = UpdateEntity(p, db);
                break;
            }
            case MSGID_DBMGR_UPDATE_ENTITY_REDIS:
            {
                nRet = UpdateEntityToRedis(p, db);
                break;
            }
            case MSGID_DBMGR_SELECT_ACCOUNT:
            {
                nRet = SelectAccount(p, db);
                break;
            }
            case MSGID_DBMGR_RAW_MODIFY_NORESP:
            {
                nRet = QueryModifyNoResp(p, db);
                break;
            }
            case MSGID_DBMGR_CREATEBASE_FROM_NAME:
            {
                nRet = LookupEntityByName(p, db);
                break;
            }
            case MSGID_DBMGR_LOAD_ALL_AVATAR:
            {
                nRet = LoadAllAvatars(p, db);
                break;
            }
            case MSGID_DBMGR_LOAD_ENTITIES_OF_TYPE:
            {
                nRet = LoadEntitiesOfType(p, db);
                break;
            }
            case MSGID_DBMGR_SHUTDOWN_SERVER:
            {
                nRet = ShutdownServer(p);
                break;
            }
            case MSGID_DBMGR_REDIS_HASH_LOAD:
            {
                nRet = RedisHashLoad(p, db);
                break;
            }
            case MSGID_DBMGR_REDIS_HASH_SET:
            {
                nRet = RedisHashSet(p, db);
                break;
            }
            case MSGID_DBMGR_REDIS_HASH_DEL:
            {
                nRet = RedisHashDel(p, db);
                break;
            }
            case MSGID_DBMGR_DEL_ACCOUNT_CACHE:
            {
                nRet = DestroyAccountCache(p);
                break;
            }

            case MSGID_DBMGR_UPDATE_ITEMS:
            {
                nRet = UpdateArrayItemsToDb(p, db);
                break;
            }
            case MSGID_DBMGR_LOADING_ITEMS:
            {
                nRet = LoadingArrayItemsToInventory(p, db);
                break;
            }
            case MSGID_DBMGR_INCREMENTAL_UPDATE_ITEMS:
            {
                nRet = IncremantalUpdateItems(p, db);
                break;
            }

            case MSGID_DBMGR_TABLE_SELECT:
            {
                nRet = TableSelect(p, db);
                break;
            }
            case MSGID_DBMGR_UPDATE_BATCH:
            {
                nRet = TableUpdateBatch(p, db);
                break;
            }
            case MSGID_DBMGR_TABLE_INSERT:
            {
                nRet = TableInsert(p, db);
                break;
            }
            case MSGID_DBMGR_TABLE_EXCUTE:
            {
                nRet = TableExcute(p, db);
                break;
            }
            case MSGID_DBMGR_TABLE2_SELECT:
            {
                nRet = Table2Select(p, db);
                break;
            }
            case MSGID_DBMGR_TABLE2_INSERT:
            {
                nRet = Table2Insert(p, db);
                break;
            }
            case MSGID_DBMGR_TABLE2_EXCUTE:
            {
                nRet = Table2Excute(p, db);
                break;
            }
            default:
            {
                break;
            }
        }

        if(nRet != 0)
        {
            LogWarning("from_rpc_call", "rpc error.msg_id=%d;ret=%d\n", msg_id, nRet);
        }

        ClearTListObject(p);

        return 0;
    }
示例#5
0
    int CWorldMgrD::FromRpcCall(CPluto& u)
    {
        //PrintHexPluto(u);

        pluto_msgid_t msg_id = u.GetMsgId();

#ifndef __TEST_LOGIN

        if(!CheckClientRpc(u))
        {
            LogWarning("from_rpc_call", "invalid rpcall error.unknown msgid:%d\n", msg_id);
            return -1;
        }

#endif // !__TEST_LOGIN

        T_VECTOR_OBJECT* p = m_rpc.Decode(u);
        if(p == NULL)
        {
            LogWarning("from_rpc_call", "rpc Decode error.unknown msgid:%d\n", msg_id);
            return -1;
        }

        if(u.GetDecodeErrIdx() > 0)
        {
            ClearTListObject(p);
            LogWarning("from_rpc_call", "rpc Decode error.msgid:%d;pluto err idx=%d\n", msg_id, u.GetDecodeErrIdx());
            return -2;
        }

        int nRet = -1;
        switch(msg_id)
        {
            case MSGID_BASEAPPMGR_REGISTERGLOBALLY:
            {
                LogInfo("CWorldMgrD::FromRpcCall() MSGID_BASEAPPMGR_REGISTERGLOBALLY", "");
                nRet = RegisterGlobally(p);
                break;
            }
            case MSGID_BASEAPPMGR_CREATEBASE_FROM_NAME_ANYWHERE:
            {
                nRet = CreateBaseFromDbByName(p);
                break;
            }
            case MSGID_BASEAPPMGR_CREATEBASE_FROM_NAME:
            {
                nRet = CreateBaseFromDbByName(p);
                break;
            }
            case MSGID_BASEAPPMGR_CREATE_CELL_IN_NEW_SPACE:
            {
                nRet = CreateCellInNewSpace(p);
                break;
            }
            case MSGID_BASEAPPMGR_CREATEBASE_ANYWHERE:
            {
                nRet = CreateBaseAnywhere(p);
                break;
            }
            case MSGID_BASEAPPMGR_SHUTDOWN_SERVERS:
            {
                nRet = ShutdownAllServers(p, u);
                break;
            }
            case MSGID_BASEAPPMGR_ON_SERVER_SHUTDOWN:
            {
                nRet = OnServerShutdown(p);
                break;
            }
        }

        if(nRet != 0)
        {
            LogWarning("from_rpc_call", "rpc error.msg_id=%d;ret=%d\n", msg_id, nRet);
        }

        ClearTListObject(p);

        return 0;
    }
示例#6
0
//in parent class , this method has a pure virtual access limited
int CWorldLogin::FromRpcCall(CPluto& u)
{
    //printf("CWorldLogin::from_rpc_call\n");
    //printf("handle pluto in FromRpcCall()! : start!\n");
	pluto_msgid_t msg_id = u.GetMsgId();
    //printf("message id : %d\n", msg_id);
	if(!CheckClientRpc(u))
	{
		LogWarning("FromRpcCall", "invalid rpcall error.unknown msgid:%d\n", msg_id);
		return -1;
	}

	T_VECTOR_OBJECT* p = m_rpc.Decode(u);
	if(p == NULL)
	{
		LogWarning("FromRpcCall", "rpc decode error.unknown msgid:%d\n", msg_id);
		return -1;
	}

	if(u.GetDecodeErrIdx() > 0)
	{
		ClearTListObject(p);
		LogWarning("FromRpcCall", "rpc decode error.msgid:%d;pluto err idx=%d\n", msg_id, u.GetDecodeErrIdx());
		return -2;
	}
    printf("MSGID_LOGINAPP_MODIFY_LOGIN_FLAG:%d\n", MSGID_LOGINAPP_MODIFY_LOGIN_FLAG);
    int nRet = -1;
    switch(msg_id)
    {
        case MSGID_LOGINAPP_LOGIN:
        {
            AddClientFdToVObjectList(u.GetMailbox()->GetFd(), p);
            nRet = AccountLogin(p);
            break;
        }
        case MSGID_LOGINAPP_SELECT_ACCOUNT_CALLBACK:
        {
            nRet = SelectAccountCallback(p);
            break;
        }
        case MSGID_LOGINAPP_NOTIFY_CLIENT_TO_ATTACH:
        {
            nRet = NotifyClientToAttach(p);
            break;
        }
	    case MSGID_LOGINAPP_MODIFY_LOGIN_FLAG:  
		{
			nRet = ModifyLoginFlag(p);
			break;
		}
	    case MSGID_ALLAPP_SHUTDOWN_SERVER://103
		{
			nRet = ShutdownServer(p);
			break;
		}
        default:
        {
            LogWarning("CWorldLogin::from_rpc_call", "unknown msgid:%d\n", msg_id);
            break;
        }
    }

	if(nRet != 0)
	{
		LogWarning("from_rpc_call", "rpc error.msg_id=%d;ret=%d\n", msg_id, nRet);
	}

    ClearTListObject(p);
    //printf("handle pluto in FromRpcCall()! : end!\n");
    return 0;
}
示例#7
0
	int CWorldOther::FromRpcCall(CPluto& u, CDbOper& db)
	{
		//printf("CWorldOther::from_rpc_call\n");
		//print_hex_pluto(u);

		pluto_msgid_t msg_id = -1;
		T_VECTOR_OBJECT* p = NULL;

		//这一段要加锁(2012/02/15改为不加锁)
		{
			//CMutexGuard _g(m_rpcMutex);

			msg_id = u.GetMsgId();
			if(!CheckClientRpc(u))
			{
				LogWarning("from_rpc_call", "invalid rpcall error.unknown msgid:%d\n", msg_id);
				return -1;
			}

			p = m_rpc.Decode(u);
			if(p == NULL)
			{
				LogWarning("from_rpc_call", "rpc Decode error.unknown msgid:%d\n", msg_id);
				return -1;
			}

			if(u.GetDecodeErrIdx() > 0)
			{
				ClearTListObject(p);
				//PrintHexPluto(u);
				LogWarning("from_rpc_call", "rpc Decode error.msgid:%d;pluto err idx=%d\n", msg_id, u.GetDecodeErrIdx());
				return -2;
			}
		}

        //这一段不用加锁
        int nRet = -1;
        switch(msg_id)
        {
            case MSGID_LOG_INSERT:
            {
                nRet = InsertDB(p, db);
                break;
            }
            case MSGID_OTHER_HTTP_REQ:
            {
                nRet = ReqUrl(p);
                break;
            }
            case MSGID_ALLAPP_SHUTDOWN_SERVER:
            {
                nRet = ShutdownServer(p);
                break;
            }
            case MSGID_OTHER_ADD_GLOBALBASE:
            {
                nRet = RegisterGlobally(p);
                break;
            }
            case MSGID_OTHER_YUNYING_API:
            {
                nRet = SupportApi(p, u.GetMailbox(), db);
                break;
            }
            case MSGID_OTHER_CLIENT_RESPONSE:
            {
                nRet = Response2Browser(p);
				PrintHexPluto(u);
                break;
            }
            //case MSGID_OTHER_LOGIN_VERIFY:
            //{
            //    //todo:verify
            //    nRet = SdkServerVerify(p, u);
            //    break;
            //}
// 			case MSGID_OTHER_PLAT_API:
// 			{
// 				nRet = PlatApi(p, u.GetMailbox(), db);
// 				break;
// 			}
            default:
            {
                LogWarning("from_rpc_call", "rpc unkown msg_id = %d\n", msg_id, nRet);
                break;
            }
        }

		if(nRet != 0)
		{
			LogWarning("from_rpc_call", "rpc error.msg_id=%d;ret=%d\n", msg_id, nRet);
		}

		ClearTListObject(p);

		return 0;
	}