示例#1
0
//-------------------------------------------------------------------------------------
bool InterfacesHandler_Interfaces::createAccount(Network::Channel* pChannel, std::string& registerName,
											  std::string& password, std::string& datas, ACCOUNT_TYPE uatype)
{
	Network::Channel* pInterfacesChannel = Dbmgr::getSingleton().networkInterface().findChannel(g_kbeSrvConfig.interfacesAddr());
	KBE_ASSERT(pInterfacesChannel);

	if(pInterfacesChannel->isDestroyed())
	{
		if(!this->reconnect())
		{
			return false;
		}
	}

	Network::Bundle* pBundle = Network::Bundle::createPoolObject();
	
	(*pBundle).newMessage(InterfacesInterface::reqCreateAccount);
	(*pBundle) << pChannel->componentID();

	uint8 accountType = uatype;
	(*pBundle) << registerName << password << accountType;
	(*pBundle).appendBlob(datas);
	pInterfacesChannel->send(pBundle);
	return true;
}
示例#2
0
//-------------------------------------------------------------------------------------
void Loginapp::onReqCreateAccountResult(Network::Channel* pChannel, MemoryStream& s)
{
	SERVER_ERROR_CODE failedcode;
	std::string accountName;
	std::string password;
	std::string retdatas = "";

	s >> failedcode >> accountName >> password;
	s.readBlob(retdatas);

	DEBUG_MSG(fmt::format("Loginapp::onReqCreateAccountResult: accountName={}, failedcode={}.\n",
		accountName.c_str(), failedcode));

	PendingLoginMgr::PLInfos* ptinfos = pendingCreateMgr_.remove(accountName);
	if(ptinfos == NULL)
		return;

	Network::Channel* pClientChannel = this->networkInterface().findChannel(ptinfos->addr);
	if(pClientChannel == NULL)
		return;

	pClientChannel->extra("");

	Network::Bundle* pBundle = Network::Bundle::ObjPool().createObject();
	(*pBundle).newMessage(ClientInterface::onCreateAccountResult);
	(*pBundle) << failedcode;
	(*pBundle).appendBlob(retdatas);

	pClientChannel->send(pBundle);
	SAFE_RELEASE(ptinfos);
}
示例#3
0
//-------------------------------------------------------------------------------------
void InterfacesHandler_Interfaces::charge(Network::Channel* pChannel, KBEngine::MemoryStream& s)
{
	Network::Channel* pInterfacesChannel = Dbmgr::getSingleton().networkInterface().findChannel(g_kbeSrvConfig.interfacesAddr());
	KBE_ASSERT(pInterfacesChannel);

	if(pInterfacesChannel->isDestroyed())
	{
		if(!this->reconnect())
			return;
	}

	std::string chargeID;
	std::string datas;
	CALLBACK_ID cbid;
	DBID dbid;

	s >> chargeID;
	s >> dbid;
	s.readBlob(datas);
	s >> cbid;

	INFO_MSG(fmt::format("InterfacesHandler_Interfaces::charge: chargeID={0}, dbid={3}, cbid={1}, datas={2}!\n",
		chargeID, cbid, datas, dbid));

	Network::Bundle* pBundle = Network::Bundle::createPoolObject();

	(*pBundle).newMessage(InterfacesInterface::charge);
	(*pBundle) << pChannel->componentID();
	(*pBundle) << chargeID;
	(*pBundle) << dbid;
	(*pBundle).appendBlob(datas);
	(*pBundle) << cbid;
	pInterfacesChannel->send(pBundle);
}
示例#4
0
//-------------------------------------------------------------------------------------
bool EntityAutoLoader::process()
{
	Network::Channel* pChannel = Components::getSingleton().getDbmgrChannel();
	if(pChannel == NULL || querying_)
		return true;

	if(entityTypes_.size() > 0)
	{
		if ((*entityTypes_.begin()).size() > 0)
		{
			Network::Bundle* pBundle = Network::Bundle::ObjPool().createObject();

			if (start_ == 0 && end_ == 0)
				end_ = LOAD_ENTITY_SIZE;

			uint16 dbInterfaceIndex = g_kbeSrvConfig.getDBMgr().dbInterfaceInfos.size() - entityTypes_.size();
			(*pBundle).newMessage(DbmgrInterface::entityAutoLoad);
			(*pBundle) << dbInterfaceIndex << g_componentID << (*(*entityTypes_.begin()).begin()) << start_ << end_;
			pChannel->send(pBundle);
			querying_ = true;
		}
		else
		{
			entityTypes_.erase(entityTypes_.begin());
		}

		return true;
	}

	delete this;
	return false;
}
示例#5
0
//-------------------------------------------------------------------------------------
void EntityIDClient::onAlloc(void)
{
	if(size() > id_enough_limit)
	{
		setReqServerAllocFlag(false);
		return;
	}
	
	if(hasReqServerAlloc())
		return;

	Network::Channel* pChannel = Components::getSingleton().getDbmgrChannel();

	if(pChannel == NULL)
	{
		ERROR_MSG("EntityIDClient::onAlloc: not found dbmgr!\n");
		return;
	}

	Network::Bundle* pBundle = Network::Bundle::createPoolObject();
	(*pBundle).newMessage(DbmgrInterface::onReqAllocEntityID);
	DbmgrInterface::onReqAllocEntityIDArgs2::staticAddToBundle((*pBundle), pApp_->componentType(), pApp_->componentID());
	pChannel->send(pBundle);

	setReqServerAllocFlag(true);

	WARNING_MSG(fmt::format("EntityIDClient::onAlloc: not enough({}) entityIDs!\n", id_enough_limit));
}
示例#6
0
//-------------------------------------------------------------------------------------
bool Proxy::sendToClient(bool expectData)
{
	if(!clientMailbox())
		return false;

	Network::Channel* pChannel = clientMailbox()->getChannel();
	if(!pChannel)
		return false;

	if(expectData)
	{
		if(pChannel->bundles().size() == 0)
		{
			WARNING_MSG("Proxy::sendToClient: no data!\n");
			return false;
		}
	}

	{
		// 如果数据大量阻塞发不出去将会报警
		AUTO_SCOPED_PROFILE("sendToClient");
		pChannel->send();
	}

	return true;
}
示例#7
0
//-------------------------------------------------------------------------------------
void LogWatcher::onMessage(LOG_ITEM* pLogItem)
{
	if(!VALID_COMPONENT(pLogItem->componentType) || filterOptions_.componentBitmap[pLogItem->componentType] == 0)
		return;

	if(filterOptions_.uid != pLogItem->uid)
		return;

	if((filterOptions_.logtypes & pLogItem->logtype) <= 0)
		return;

	if(filterOptions_.globalOrder > 0 && filterOptions_.globalOrder != pLogItem->componentGlobalOrder)
		return;

	if(filterOptions_.groupOrder > 0 && filterOptions_.groupOrder != pLogItem->componentGroupOrder)
		return;

	Network::Channel* pChannel = Logger::getSingleton().networkInterface().findChannel(addr_);

	if(pChannel == NULL)
		return;

	if(!validDate_(pLogItem->logstream.str()) || !containKeyworlds_(pLogItem->logstream.str()))
		return;

	Network::Bundle* pBundle = Network::Bundle::createPoolObject();
	ConsoleInterface::ConsoleLogMessageHandler msgHandler;
	(*pBundle).newMessage(msgHandler);
	(*pBundle) << pLogItem->logstream.str().c_str();
	pChannel->send(pBundle);
}
示例#8
0
//-------------------------------------------------------------------------------------
bool Proxy::pushBundle(Network::Bundle* pBundle)
{
	if(!clientMailbox())
		return false;

	Network::Channel* pChannel = clientMailbox()->getChannel();
	if(!pChannel)
		return false;

	pChannel->send(pBundle);
	return true;
}
//-------------------------------------------------------------------------------------
bool SyncEntityStreamTemplateHandler::process()
{
	Components::COMPONENTS& cts = Components::getSingleton().getComponents(DBMGR_TYPE);
	Network::Channel* pChannel = NULL;

	if(cts.size() > 0)
	{
		Components::COMPONENTS::iterator ctiter = cts.begin();
		if((*ctiter).pChannel == NULL)
			return true;

		pChannel = (*ctiter).pChannel;
	}

	if(pChannel == NULL)
		return true;

	MemoryStream accountDefMemoryStream;

	ENGINE_COMPONENT_INFO& dbcfg = g_kbeSrvConfig.getDBMgr();

	ScriptDefModule* scriptModule = EntityDef::findScriptModule(dbcfg.dbAccountEntityScriptType);
	if(scriptModule == NULL)
	{
		delete this;
		return false;
	}

	ScriptDefModule::PROPERTYDESCRIPTION_MAP& propertyDescrs = scriptModule->getPersistentPropertyDescriptions();
	ScriptDefModule::PROPERTYDESCRIPTION_MAP::const_iterator iter = propertyDescrs.begin();

	if(scriptModule->hasCell())
	{
		Vector3 pos, dir;
		ADD_POSDIR_TO_STREAM(accountDefMemoryStream, pos, dir);
	}

	for(; iter != propertyDescrs.end(); ++iter)
	{
		PropertyDescription* propertyDescription = iter->second;
		accountDefMemoryStream << propertyDescription->getUType();
		propertyDescription->addPersistentToStream(&accountDefMemoryStream, NULL);
	}

	Network::Bundle* pBundle = Network::Bundle::ObjPool().createObject();

	(*pBundle).newMessage(DbmgrInterface::syncEntityStreamTemplate);
	(*pBundle).append(accountDefMemoryStream);
	pChannel->send(pBundle);
	delete this;
	return false;
}
示例#10
0
//-------------------------------------------------------------------------------------
void Loginapp::onReqCreateAccountResult(Network::Channel* pChannel, MemoryStream& s)
{
	SERVER_ERROR_CODE failedcode;
	std::string accountName;
	std::string password;
	std::string retdatas = "";

	s >> failedcode >> accountName >> password;
	s.readBlob(retdatas);

	// 把请求交由脚本处理
	SCOPED_PROFILE(SCRIPTCALL_PROFILE);
	PyObject* pyResult = PyObject_CallMethod(getEntryScript().get(), 
										const_cast<char*>("onCreateAccountCallbackFromDB"), 
										const_cast<char*>("sHy#"), 
										accountName.c_str(),
										failedcode,
										retdatas.c_str(), retdatas.length());

	if(pyResult != NULL)
	{
		Py_DECREF(pyResult);
	}
	else
	{
		SCRIPT_ERROR_CHECK();
	}

	DEBUG_MSG(fmt::format("Loginapp::onReqCreateAccountResult: accountName={}, failedcode={}.\n",
		accountName.c_str(), failedcode));

	PendingLoginMgr::PLInfos* ptinfos = pendingCreateMgr_.remove(accountName);
	if(ptinfos == NULL)
		return;

	Network::Channel* pClientChannel = this->networkInterface().findChannel(ptinfos->addr);
	if(pClientChannel == NULL)
		return;

	pClientChannel->extra("");

	Network::Bundle* pBundle = Network::Bundle::createPoolObject();
	(*pBundle).newMessage(ClientInterface::onCreateAccountResult);
	(*pBundle) << failedcode;
	(*pBundle).appendBlob(retdatas);

	pClientChannel->send(pBundle);
	SAFE_RELEASE(ptinfos);
}
示例#11
0
//-------------------------------------------------------------------------------------
void InterfacesHandler_Interfaces::eraseClientReq(Network::Channel* pChannel, std::string& logkey)
{
	Network::Channel* pInterfacesChannel = Dbmgr::getSingleton().networkInterface().findChannel(g_kbeSrvConfig.interfacesAddr());
	KBE_ASSERT(pInterfacesChannel);

	if(pInterfacesChannel->isDestroyed())
	{
		if(!this->reconnect())
			return;
	}

	Network::Bundle* pBundle = Network::Bundle::createPoolObject();

	(*pBundle).newMessage(InterfacesInterface::eraseClientReq);
	(*pBundle) << logkey;
	pInterfacesChannel->send(pBundle);
}
示例#12
0
//-------------------------------------------------------------------------------------
void Interfaces::accountLoginResponse(std::string commitName, std::string realAccountName, 
	std::string extraDatas, KBEngine::SERVER_ERROR_CODE errorCode)
{
	REQLOGIN_MAP::iterator iter = reqAccountLogin_requests_.find(commitName);
	if (iter == reqAccountLogin_requests_.end())
	{
		// 理论上不可能找不到,但如果真找不到,这是个很恐怖的事情,必须写日志记录下来
		ERROR_MSG(fmt::format("Interfaces::accountLoginResponse: commitName '{}' not found!" \
			"realAccountName = '{}', extra datas = '{}', error code = '{}'\n", 
			commitName, 
			realAccountName, 
			extraDatas, 
			errorCode));

		return;
	}

	LoginAccountTask *task = iter->second;

	Network::Bundle* pBundle = Network::Bundle::createPoolObject();
	
	(*pBundle).newMessage(DbmgrInterface::onLoginAccountCBBFromInterfaces);
	(*pBundle) << task->baseappID << commitName << realAccountName << task->password << errorCode;

	(*pBundle).appendBlob(task->postDatas);
	(*pBundle).appendBlob(extraDatas);

	Network::Channel* pChannel = Interfaces::getSingleton().networkInterface().findChannel(task->address);

	if(pChannel)
	{
		pChannel->send(pBundle);
	}
	else
	{
		ERROR_MSG(fmt::format("Interfaces::accountLoginResponse: not found channel. commitName={}\n", commitName));
		Network::Bundle::reclaimPoolObject(pBundle);
	}

	// 清理
	reqAccountLogin_requests_.erase(iter);
	delete task;
}
//-------------------------------------------------------------------------------------
bool EntityMailboxAbstract::postMail(Network::Bundle* pBundle)
{
    KBE_ASSERT(Components::getSingleton().pNetworkInterface() != NULL);
    Network::Channel* pChannel = getChannel();

    if(pChannel && !pChannel->isDead())
    {
        pChannel->send(pBundle);
        return true;
    }
    else
    {
        ERROR_MSG(fmt::format("EntityMailboxAbstract::postMail: invalid channel({})!\n",
                              addr_.c_str()));
    }

    Network::Bundle::ObjPool().reclaimObject(pBundle);
    return false;
}
示例#14
0
//-------------------------------------------------------------------------------------
void NetworkProfileHandler::sendStream(MemoryStream* s)
{
	Network::Channel* pChannel = networkInterface_.findChannel(addr_);
	if(pChannel == NULL)
	{
		WARNING_MSG(fmt::format("NetworkProfileHandler::sendStream: not found {} addr({})\n",
			name_, addr_.c_str()));
		return;
	}

	Network::Bundle* pBundle = Network::Bundle::createPoolObject();

	ConsoleInterface::ConsoleProfileHandler msgHandler;
	(*pBundle).newMessage(msgHandler);

	int8 type = 3;
	(*pBundle) << type;
	(*pBundle).append(s);
	pChannel->send(pBundle);
}
示例#15
0
//-------------------------------------------------------------------------------------
void Interfaces::chargeResponse(std::string orderID, std::string extraDatas, KBEngine::SERVER_ERROR_CODE errorCode)
{
	ORDERS::iterator iter = orders_.find(orderID);
	if (iter == orders_.end())
	{
		// 理论上不可能找不到,但如果真找不到,这是个很恐怖的事情,必须写日志记录下来
		ERROR_MSG(fmt::format("Interfaces::chargeResponse: order id '{}' not found! extra datas = '{}', error code = '{}'", 
			orderID, 
			extraDatas, 
			errorCode));
		return;
	}

	KBEShared_ptr<Orders> orders = iter->second;
	Network::Bundle* pBundle = Network::Bundle::createPoolObject();

	(*pBundle).newMessage(DbmgrInterface::onChargeCB);
	(*pBundle) << orders->baseappID << orders->ordersID << orders->dbid;
	(*pBundle).appendBlob(orders->getDatas);
	(*pBundle) << orders->cbid;
	(*pBundle) << errorCode;

	Network::Channel* pChannel = networkInterface().findChannel(orders->address);

	if(pChannel)
	{
		WARNING_MSG(fmt::format("Interfaces::chargeResponse: orders={} commit is failed!\n", 
			orders->ordersID));

		pChannel->send(pBundle);
	}
	else
	{
		ERROR_MSG(fmt::format("Interfaces::chargeResponse: not found channel. orders={}\n", 
			orders->ordersID));

		Network::Bundle::reclaimPoolObject(pBundle);
	}

	orders_.erase(iter);
}
示例#16
0
//-------------------------------------------------------------------------------------
void GlobalDataClient::onDataChanged(PyObject* key, PyObject* value, bool isDelete)
{
	std::string skey = script::Pickler::pickle(key, 0);
	std::string sval = "";

	if(value)
		sval = script::Pickler::pickle(value, 0);

	Components::COMPONENTS& channels = Components::getSingleton().getComponents(serverComponentType_);
	Components::COMPONENTS::iterator iter1 = channels.begin();
	uint8 dataType = dataType_;
	ArraySize slen = 0;

	for(; iter1 != channels.end(); ++iter1)
	{
		Network::Channel* lpChannel = iter1->pChannel;
		KBE_ASSERT(lpChannel != NULL);
		
		Network::Bundle* pBundle = Network::Bundle::createPoolObject();
		
		(*pBundle).newMessage(DbmgrInterface::onBroadcastGlobalDataChanged);
		
		(*pBundle) << dataType;
		(*pBundle) << isDelete;

		slen = skey.size();
		(*pBundle) << slen;
		(*pBundle).assign(skey.data(), slen);

		if(!isDelete)
		{
			slen = sval.size();
			(*pBundle) << slen;
			(*pBundle).assign(sval.data(), slen);
		}

		(*pBundle) << g_componentType;

		lpChannel->send(pBundle);
	}
}
示例#17
0
//-------------------------------------------------------------------------------------
bool InterfacesHandler_Interfaces::loginAccount(Network::Channel* pChannel, std::string& loginName,
											 std::string& password, std::string& datas)
{
	Network::Channel* pInterfacesChannel = Dbmgr::getSingleton().networkInterface().findChannel(g_kbeSrvConfig.interfacesAddr());
	KBE_ASSERT(pInterfacesChannel);

	if(pInterfacesChannel->isDestroyed())
	{
		if(!this->reconnect())
			return false;
	}

	Network::Bundle* pBundle = Network::Bundle::createPoolObject();

	(*pBundle).newMessage(InterfacesInterface::onAccountLogin);
	(*pBundle) << pChannel->componentID();
	(*pBundle) << loginName << password;
	(*pBundle).appendBlob(datas);
	pInterfacesChannel->send(pBundle);
	return true;
}
示例#18
0
//-------------------------------------------------------------------------------------
void SpaceViewer::sendStream(MemoryStream* s, int type)
{
	Network::Channel* pChannel = Cellapp::getSingleton().networkInterface().findChannel(addr_);
	if(pChannel == NULL)
	{
		WARNING_MSG(fmt::format("SpaceViewer::sendStream: not found addr({})\n",
			addr_.c_str()));

		return;
	}

	Network::Bundle* pBundle = Network::Bundle::createPoolObject();

	ConsoleInterface::ConsoleQuerySpacesHandler msgHandler;
	(*pBundle).newMessage(msgHandler);

	(*pBundle) << g_componentType;
	(*pBundle) << g_componentID;
	(*pBundle) << type;
	(*pBundle).append(s);
	pChannel->send(pBundle);
}
示例#19
0
//-------------------------------------------------------------------------------------
bool ForwardAnywhere_MessageBuffer::process()
{
	if(pBundles_.size() <= 0)
	{
		start_ = false;
		return false;
	}
	
	Components::COMPONENTS& cts = Components::getSingleton().getComponents(forwardComponentType_);
	size_t idx = 0;

	if(cts.size() > 0)
	{
		bool hasEnabled = (g_componentType != CELLAPPMGR_TYPE && g_componentType != BASEAPPMGR_TYPE);

		Components::COMPONENTS::iterator ctiter = cts.begin();
		for(; ctiter != cts.end(); ++ctiter)
		{
			// 必须所有的组件频道都被设置,如果不是则等待。
			if((*ctiter).pChannel == NULL)
				return true;

			if((*ctiter).state == COMPONENT_STATE_RUN)
				hasEnabled = true;
		}

		// 必须有可用的进程
		if(!hasEnabled)
			return true;

		// 最多每个tick处理5个
		int icount = 5;

		std::vector<ForwardItem*>::iterator iter = pBundles_.begin();
		for(; iter != pBundles_.end(); )
		{
			Network::Channel* pChannel = NULL;
			
			if(g_componentType != CELLAPPMGR_TYPE && g_componentType != BASEAPPMGR_TYPE)
			{
				pChannel = cts[idx++].pChannel;
				if(idx >= cts.size())
					idx = 0;
			}
			else
			{
				while(pChannel == NULL)
				{
					if(cts[idx].state != COMPONENT_STATE_RUN)
					{
						if(++idx >= cts.size())
							idx = 0;

						continue;
					}

					pChannel = cts[idx++].pChannel;
					if(idx >= cts.size())
						idx = 0;
				}
			}

			pChannel->send((*iter)->pBundle);
			(*iter)->pBundle = NULL;

			if((*iter)->pHandler != NULL)
			{
				(*iter)->pHandler->process();
				SAFE_RELEASE((*iter)->pHandler);
			}
			
			SAFE_RELEASE((*iter));

			iter = pBundles_.erase(iter);

			if(--icount <= 0)
				return true;
		}
		
		DEBUG_MSG(fmt::format("ForwardAnywhere_MessageBuffer::process(): size:{}.\n", pBundles_.size()));
		start_ = false;
		return false;
	}

	return true;
}
示例#20
0
//-------------------------------------------------------------------------------------
void Interfaces::chargeResponse(std::string orderID, std::string extraDatas, KBEngine::SERVER_ERROR_CODE errorCode)
{
	ORDERS::iterator iter = orders_.find(orderID);
	if (iter == orders_.end())
	{
		ERROR_MSG(fmt::format("Interfaces::chargeResponse: order id '{}' not found! extra datas = '{}', error code = '{}'\n", 
			orderID, 
			extraDatas, 
			errorCode));
		
		// 这种情况也需要baseapp处理onLoseChargeCB
		// 例如某些时候客户端出问题未向服务器注册这个订单号,但是计费平台有返回的情况
		// 将订单发送给注册的所有的dbmgr
		const Network::NetworkInterface::ChannelMap& channels = Interfaces::getSingleton().networkInterface().channels();
		if(channels.size() > 0)
		{
			Network::NetworkInterface::ChannelMap::const_iterator channeliter = channels.begin();
			for(; channeliter != channels.end(); ++channeliter)
			{
				Network::Channel* pChannel = channeliter->second;
				if(pChannel)
				{
					COMPONENT_ID baseappID = 0;
					DBID dbid = 0;
					CALLBACK_ID cbid = 0;

					Network::Bundle* pBundle = Network::Bundle::createPoolObject();

					(*pBundle).newMessage(DbmgrInterface::onChargeCB);
					(*pBundle) << baseappID << orderID << dbid;
					(*pBundle).appendBlob(extraDatas);
					(*pBundle) << cbid;
					(*pBundle) << errorCode;
					pChannel->send(pBundle);
				}
			}
		}
		else
		{
			ERROR_MSG(fmt::format("Interfaces::chargeResponse: not found channels. orders={}, datas={}\n", 
				orderID, extraDatas));
		}

		return;
	}

	KBEShared_ptr<Orders> orders = iter->second;
	orders->getDatas = extraDatas;

	Network::Bundle* pBundle = Network::Bundle::createPoolObject();

	(*pBundle).newMessage(DbmgrInterface::onChargeCB);
	(*pBundle) << orders->baseappID << orders->ordersID << orders->dbid;
	(*pBundle).appendBlob(orders->getDatas);
	(*pBundle) << orders->cbid;
	(*pBundle) << errorCode;

	Network::Channel* pChannel = networkInterface().findChannel(orders->address);

	if(pChannel)
	{
		pChannel->send(pBundle);
	}
	else
	{
		ERROR_MSG(fmt::format("Interfaces::chargeResponse: not found channels. orders={}, datas={}\n", 
			orderID, extraDatas));

		Network::Bundle::reclaimPoolObject(pBundle);
	}

	orders_.erase(iter);
}
示例#21
0
//-------------------------------------------------------------------------------------
bool InitProgressHandler::process()
{
	if(error_)
	{
		Baseapp::getSingleton().dispatcher().breakProcessing();
		return false;
	}

	Network::Channel* pChannel = Components::getSingleton().getBaseappmgrChannel();

	if(pChannel == NULL)
		return true;

	if(Baseapp::getSingleton().idClient().getSize() == 0)
		return true;

	if(delayTicks_++ < 1)
		return true;

	// 只有第一个baseapp上会创建EntityAutoLoader来自动加载数据库实体
	if(g_componentGroupOrder == 1)
	{
		if(autoLoadState_ == -1)
		{
			autoLoadState_ = 0;
			pEntityAutoLoader_ = new EntityAutoLoader(networkInterface_, this);
			return true;
		}
		else if(autoLoadState_ == 0)
		{
			// 必须等待EntityAutoLoader执行完毕
			// EntityAutoLoader执行完毕会设置autoLoadState_ = 1
			return true;
		}
	}

	pEntityAutoLoader_ = NULL;

	if(!baseappReady_)
	{
		baseappReady_ = true;

		SCOPED_PROFILE(SCRIPTCALL_PROFILE);

		// 所有脚本都加载完毕
		PyObject* pyResult = PyObject_CallMethod(Baseapp::getSingleton().getEntryScript().get(), 
											const_cast<char*>("onBaseAppReady"), 
											const_cast<char*>("O"), 
											PyBool_FromLong((g_componentGroupOrder == 1) ? 1 : 0));

		if(pyResult != NULL)
			Py_DECREF(pyResult);
		else
			SCRIPT_ERROR_CHECK();

		return true;
	}

	float v = 0.0f;
	bool completed = false;

	if(PyObject_HasAttrString(Baseapp::getSingleton().getEntryScript().get(), "onReadyForLogin") > 0)
	{
		SCOPED_PROFILE(SCRIPTCALL_PROFILE);

		// 回调获得是否能够登录
		PyObject* pyResult = PyObject_CallMethod(Baseapp::getSingleton().getEntryScript().get(), 
											const_cast<char*>("onReadyForLogin"), 
											const_cast<char*>("O"), 
											PyBool_FromLong((g_componentGroupOrder == 1) ? 1 : 0));

		if(pyResult != NULL)
		{
			completed = (pyResult == Py_True);
			
			if(!completed)
			{
				v = (float)PyFloat_AsDouble(pyResult);
				if (PyErr_Occurred())
				{
					SCRIPT_ERROR_CHECK();
					Py_DECREF(pyResult);
					return true;
				}
			}
			else
			{
				v = 100.f;
			}

			Py_DECREF(pyResult);
		}
		else
		{
			SCRIPT_ERROR_CHECK();
			return true;
		}
	}
	else
	{
		v = 100.f;
		completed = true;
	}
	
	if(v >= 0.9999f)
	{
		v = 100.f;
		completed = true;
	}

	Network::Bundle* pBundle = Network::Bundle::ObjPool().createObject();

	(*pBundle).newMessage(BaseappmgrInterface::onBaseappInitProgress);
	(*pBundle) << g_componentID << v;
	pChannel->send(pBundle);

	if(completed)
	{
		delete this;
		return false;
	}

	return true;
}
示例#22
0
//-------------------------------------------------------------------------------------
bool InitProgressHandler::process()
{
	Components::COMPONENTS& cts = Components::getSingleton().getComponents(CELLAPPMGR_TYPE);
	Network::Channel* pChannel = NULL;

	if(cts.size() > 0)
	{
		Components::COMPONENTS::iterator ctiter = cts.begin();
		if((*ctiter).pChannel == NULL)
			return true;

		pChannel = (*ctiter).pChannel;
	}

	if(pChannel == NULL)
		return true;

	if(Cellapp::getSingleton().idClient().size() == 0)
		return true;

	if(delayTicks_++ < 1)
		return true;

	float v = 0.0f;
	bool completed = false;

	if(PyObject_HasAttrString(Cellapp::getSingleton().getEntryScript().get(), "onReadyForLogin") > 0)
	{
		// 所有脚本都加载完毕
		PyObject* pyResult = PyObject_CallMethod(Cellapp::getSingleton().getEntryScript().get(), 
											const_cast<char*>("onReadyForLogin"), 
											const_cast<char*>("i"), 
											g_componentGroupOrder);

		if(pyResult != NULL)
		{
			completed = (pyResult == Py_True);
			
			if(!completed)
			{
				v = (float)PyFloat_AsDouble(pyResult);
				if (PyErr_Occurred())
				{
					SCRIPT_ERROR_CHECK();
					Py_DECREF(pyResult);
					return true;
				}
			}
			else
			{
				v = 100.f;
			}

			Py_DECREF(pyResult);
		}
		else
		{
			SCRIPT_ERROR_CHECK();
			return true;
		}
	}
	else
	{
		v = 100.f;
		completed = true;
	}
	
	if(v >= 0.9999f)
	{
		v = 100.f;
		completed = true;
	}

	Network::Bundle* pBundle = Network::Bundle::createPoolObject();

	(*pBundle).newMessage(CellappmgrInterface::onCellappInitProgress);
	(*pBundle) << g_componentID << v << g_componentGlobalOrder << g_componentGroupOrder;
	pChannel->send(pBundle);

	if(completed)
	{
		delete this;
		return false;
	}

	return true;
}
示例#23
0
void CLogWindow::pullLogs(KBEngine::Network::Address addr)
{
    CguiconsoleDlg* dlg = static_cast<CguiconsoleDlg*>(theApp.m_pMainWnd);
    Network::Channel* pChannel = dlg->networkInterface().findChannel(addr);
    if(pChannel == NULL)
    {
        ::AfxMessageBox(L"logger is error!");
        return;
    }

    if(!pulling)
    {
        Network::Bundle* pBundle = Network::Bundle::createPoolObject();
        (*pBundle).newMessage(LoggerInterface::registerLogWatcher);

        int32 uid = dlg->getSelTreeItemUID();
        (*pBundle) << uid;

        (*pBundle) << getSelLogTypes();

        CString apporder;
        m_appIDEdit.GetWindowTextW(apporder);

        char* cs = KBEngine::strutil::wchar2char(apporder.GetBuffer(0));
        COMPONENT_ORDER order = atoi(cs);
        free(cs);

        (*pBundle) << order;

        m_appIDEdit1.GetWindowTextW(apporder);
        cs = KBEngine::strutil::wchar2char(apporder.GetBuffer(0));
        order = atoi(cs);
        free(cs);

        (*pBundle) << order;

        CString date;
        m_dateEdit.GetWindowTextW(date);
        cs = KBEngine::strutil::wchar2char(date.GetBuffer(0));
        (*pBundle) << cs;
        free(cs);

        CString keystr;
        m_findEdit.GetWindowTextW(keystr);
        cs = KBEngine::strutil::wchar2char(keystr.GetBuffer(0));
        (*pBundle) << cs;
        free(cs);

        int8 count = 0;
        std::vector<KBEngine::COMPONENT_TYPE> vec = getSelComponents();
        count = vec.size();
        (*pBundle) << count;
        std::vector<KBEngine::COMPONENT_TYPE>::iterator iter = vec.begin();
        for(; iter != vec.end(); iter++)
        {
            (*pBundle) << (*iter);
        }

        (*pBundle) << isfind_;

        bool first = m_loglist.GetCount() <= 0;
        (*pBundle) << first;
        pChannel->send(pBundle);

        m_autopull.SetWindowTextW(L"stop");
    }
    else
    {
        m_autopull.SetWindowTextW(L"auto");

        Network::Bundle* pBundle = Network::Bundle::createPoolObject();
        (*pBundle).newMessage(LoggerInterface::deregisterLogWatcher);
        pChannel->send(pBundle);
    }

    pulling = !pulling;
}
示例#24
0
void CLogWindow::updateSettingToServer()
{
    Network::Bundle* pBundle = Network::Bundle::createPoolObject();
    (*pBundle).newMessage(LoggerInterface::updateLogWatcherSetting);

    CguiconsoleDlg* dlg = static_cast<CguiconsoleDlg*>(theApp.m_pMainWnd);
    int32 uid = dlg->getSelTreeItemUID();
    (*pBundle) << uid;

    (*pBundle) << getSelLogTypes();

    CString apporder;
    m_appIDEdit.GetWindowTextW(apporder);

    char* cs = KBEngine::strutil::wchar2char(apporder.GetBuffer(0));
    COMPONENT_ORDER order = atoi(cs);
    free(cs);

    (*pBundle) << order;

    m_appIDEdit1.GetWindowTextW(apporder);
    cs = KBEngine::strutil::wchar2char(apporder.GetBuffer(0));
    order = atoi(cs);
    free(cs);

    (*pBundle) << order;

    CString date;
    m_dateEdit.GetWindowTextW(date);
    cs = KBEngine::strutil::wchar2char(date.GetBuffer(0));
    (*pBundle) << cs;
    free(cs);

    CString keystr;
    m_findEdit.GetWindowTextW(keystr);
    cs = KBEngine::strutil::wchar2char(keystr.GetBuffer(0));
    (*pBundle) << cs;
    free(cs);

    int8 count = 0;
    std::vector<KBEngine::COMPONENT_TYPE> vec = getSelComponents();
    count = vec.size();
    (*pBundle) << count;
    std::vector<KBEngine::COMPONENT_TYPE>::iterator iter = vec.begin();
    for(; iter != vec.end(); iter++)
    {
        (*pBundle) << (*iter);
    }

    HTREEITEM item = dlg->hasCheckApp(LOGGER_TYPE);
    if(item == NULL)
    {
        ::AfxMessageBox(L"logger no select!");
        Network::Bundle::reclaimPoolObject(pBundle);
        return;
    }

    dlg = static_cast<CguiconsoleDlg*>(theApp.m_pMainWnd);
    Network::Address addr = dlg->getTreeItemAddr(item);
    Network::Channel* pChannel = dlg->networkInterface().findChannel(addr);
    if(pChannel == NULL)
    {
        ::AfxMessageBox(L"logger is error!");
        Network::Bundle::reclaimPoolObject(pBundle);
        return;
    }

    bool first = m_loglist.GetCount() <= 0;
    (*pBundle) << first;
    pChannel->send(pBundle);
}
示例#25
0
//-------------------------------------------------------------------------------------
void Loginapp::onReqCreateMailAccountResult(Network::Channel* pChannel, MemoryStream& s)
{
	SERVER_ERROR_CODE failedcode;
	std::string accountName;
	std::string password;
	std::string retdatas = "";

	s >> failedcode >> accountName >> password;
	s.readBlob(retdatas);

	DEBUG_MSG(fmt::format("Loginapp::onReqCreateMailAccountResult: accountName={}, failedcode={}.\n",
		accountName.c_str(), failedcode));

	if(failedcode == SERVER_SUCCESS)
	{
		Components::COMPONENTS& loginapps = Components::getSingleton().getComponents(LOGINAPP_TYPE);

		std::string http_host = "localhost";
		if(startGroupOrder_ == 1)
		{
			if(strlen((const char*)&g_kbeSrvConfig.getLoginApp().externalAddress) > 0)
				http_host = g_kbeSrvConfig.getBaseApp().externalAddress;
			else
				http_host = inet_ntoa((struct in_addr&)Loginapp::getSingleton().networkInterface().extaddr().ip);
		}
		else
		{
			Components::COMPONENTS::iterator iter = loginapps.begin();
			for(; iter != loginapps.end(); ++iter)
			{
				if((*iter).groupOrderid == 1)
				{
					if(strlen((const char*)&(*iter).externalAddressEx) > 0)
						http_host = (*iter).externalAddressEx;
					else
						http_host = inet_ntoa((struct in_addr&)(*iter).pExtAddr->ip);
				}
			}
		}

		threadPool_.addTask(new SendActivateEMailTask(accountName, retdatas, 
			http_host, 
			g_kbeSrvConfig.getLoginApp().http_cbport));
	}

	PendingLoginMgr::PLInfos* ptinfos = pendingCreateMgr_.remove(accountName);
	if(ptinfos == NULL)
		return;

	Network::Channel* pClientChannel = this->networkInterface().findChannel(ptinfos->addr);
	if(pClientChannel == NULL)
		return;

	pClientChannel->extra("");
	retdatas = "";

	Network::Bundle* pBundle = Network::Bundle::createPoolObject();
	(*pBundle).newMessage(ClientInterface::onCreateAccountResult);
	(*pBundle) << failedcode;
	(*pBundle).appendBlob(retdatas);

	pClientChannel->send(pBundle);

	SAFE_RELEASE(ptinfos);
}