Beispiel #1
0
//-------------------------------------------------------------------------------------
void Baseappmgr::registerPendingAccountToBaseapp(Network::Channel* pChannel, MemoryStream& s)
{
	std::string loginName;
	std::string accountName;
	std::string password;
	std::string datas;
	DBID entityDBID;
	uint32 flags;
	uint64 deadline;
	COMPONENT_TYPE componentType;

	s >> loginName >> accountName >> password >> entityDBID >> flags >> deadline >> componentType;
	s.readBlob(datas);

	Components::ComponentInfos* cinfos = Components::getSingleton().findComponent(pChannel);
	if(cinfos == NULL || cinfos->pChannel == NULL)
	{
		ERROR_MSG("Baseappmgr::registerPendingAccountToBaseapp: not found loginapp!\n");
		return;
	}

	pending_logins_[loginName] = cinfos->cid;

	ENTITY_ID eid = 0;
	cinfos = Components::getSingleton().findComponent(BASEAPP_TYPE, bestBaseappID_);

	if(cinfos == NULL || cinfos->pChannel == NULL || cinfos->state != COMPONENT_STATE_RUN)
	{
		Network::Bundle* pBundle = Network::Bundle::ObjPool().createObject();
		ForwardItem* pFI = new ForwardItem();

		pFI->pBundle = pBundle;
		(*pBundle).newMessage(BaseappInterface::registerPendingLogin);
		(*pBundle) << loginName << accountName << password << eid << entityDBID << flags << deadline << componentType;
		pBundle->appendBlob(datas);

		WARNING_MSG("Baseappmgr::registerPendingAccountToBaseapp: not found baseapp, message is buffered.\n");
		pFI->pHandler = NULL;
		forward_baseapp_messagebuffer_.push(pFI);
		return;
	}


	DEBUG_MSG(fmt::format("Baseappmgr::registerPendingAccountToBaseapp:{0}. allocBaseapp=[{1}].\n",
		accountName, bestBaseappID_));
	
	Network::Bundle* pBundle = Network::Bundle::ObjPool().createObject();
	(*pBundle).newMessage(BaseappInterface::registerPendingLogin);
	(*pBundle) << loginName << accountName << password << eid << entityDBID << flags << deadline << componentType;
	pBundle->appendBlob(datas);
	cinfos->pChannel->send(pBundle);
}
Beispiel #2
0
//-------------------------------------------------------------------------------------
void Baseappmgr::registerPendingAccountToBaseappAddr(Network::Channel* pChannel, MemoryStream& s)
{
	COMPONENT_ID componentID;
	std::string loginName;
	std::string accountName;
	std::string password;
	std::string datas;
	ENTITY_ID entityID;
	DBID entityDBID;
	uint32 flags;
	uint64 deadline;
	COMPONENT_TYPE componentType;

	s >> componentID >> loginName >> accountName >> password >> entityID >> entityDBID >> flags >> deadline >> componentType;
	s.readBlob(datas);

	DEBUG_MSG(fmt::format("Baseappmgr::registerPendingAccountToBaseappAddr:{0}, componentID={1}, entityID={2}.\n",
		accountName, componentID, entityID));

	Components::ComponentInfos* cinfos = Components::getSingleton().findComponent(pChannel);
	if(cinfos == NULL || cinfos->pChannel == NULL)
	{
		ERROR_MSG("Baseappmgr::registerPendingAccountToBaseapp: not found loginapp!\n");
		return;
	}

	pending_logins_[loginName] = cinfos->cid;

	cinfos = Components::getSingleton().findComponent(componentID);
	if(cinfos == NULL || cinfos->pChannel == NULL)
	{
		ERROR_MSG(fmt::format("Baseappmgr::registerPendingAccountToBaseappAddr: not found baseapp({}).\n", componentID));
		sendAllocatedBaseappAddr(pChannel, loginName, accountName, "", 0);
		return;
	}
	
	Network::Bundle* pBundle = Network::Bundle::ObjPool().createObject();
	(*pBundle).newMessage(BaseappInterface::registerPendingLogin);
	(*pBundle) << loginName << accountName << password << entityID << entityDBID << flags << deadline << componentType;
	pBundle->appendBlob(datas);
	cinfos->pChannel->send(pBundle);
}
Beispiel #3
0
//-------------------------------------------------------------------------------------
void Baseappmgr::registerPendingAccountToBaseapp(Network::Channel* pChannel, MemoryStream& s)
{
    std::string loginName;
    std::string accountName;
    std::string password;
    std::string datas;
    DBID entityDBID;
    uint32 flags;
    uint64 deadline;
    COMPONENT_TYPE componentType;

    s >> loginName >> accountName >> password >> entityDBID >> flags >> deadline >> componentType;
    s.readBlob(datas);

    Components::ComponentInfos* cinfos = Components::getSingleton().findComponent(pChannel);
    if(cinfos == NULL || cinfos->pChannel == NULL)
    {
        ERROR_MSG("Baseappmgr::registerPendingAccountToBaseapp: not found loginapp!\n");
        return;
    }

    pending_logins_[loginName] = cinfos->cid;

    updateBestBaseapp();

    if (bestBaseappID_ == 0 && numLoadBalancingApp() == 0)
    {
        ERROR_MSG(fmt::format("Baseappmgr::registerPendingAccountToBaseapp: Unable to allocate baseapp for load balancing! baseappSize={}, accountName={}.\n",
                              baseapps_.size(), loginName));
    }

    ENTITY_ID eid = 0;
    cinfos = Components::getSingleton().findComponent(BASEAPP_TYPE, bestBaseappID_);

    if (cinfos == NULL || cinfos->pChannel == NULL || cinfos->state != COMPONENT_STATE_RUN)
    {
        Network::Bundle* pBundle = Network::Bundle::createPoolObject();
        ForwardItem* pFI = new AppForwardItem();

        pFI->pBundle = pBundle;
        (*pBundle).newMessage(BaseappInterface::registerPendingLogin);
        (*pBundle) << loginName << accountName << password << eid << entityDBID << flags << deadline << componentType;
        pBundle->appendBlob(datas);

        int runstate = -1;
        if (cinfos)
            runstate = (int)cinfos->state;

        WARNING_MSG(fmt::format("Baseappmgr::registerPendingAccountToBaseapp: not found baseapp({}, runstate={}, pChannel={}), message is buffered.\n",
                                bestBaseappID_, runstate, (cinfos && cinfos->pChannel ? cinfos->pChannel->c_str() : "NULL")));

        pFI->pHandler = NULL;
        forward_anywhere_baseapp_messagebuffer_.push(pFI);
        return;
    }

    std::map< COMPONENT_ID, Baseapp >::iterator baseapps_iter = baseapps_.find(bestBaseappID_);

    DEBUG_MSG(fmt::format("Baseappmgr::registerPendingAccountToBaseapp:{}. allocBaseapp={}, numEntities={}.\n",
                          accountName, bestBaseappID_, (bestBaseappID_ > 0 ? baseapps_iter->second.numEntities() : 0)));

    Network::Bundle* pBundle = Network::Bundle::createPoolObject();
    (*pBundle).newMessage(BaseappInterface::registerPendingLogin);
    (*pBundle) << loginName << accountName << password << eid << entityDBID << flags << deadline << componentType;
    pBundle->appendBlob(datas);
    cinfos->pChannel->send(pBundle);

    // 预先将实体数量增加
    if (baseapps_iter != baseapps_.end())
    {
        baseapps_iter->second.incNumProxices();
    }
}