本文整理汇总了C++中network::Channel类的典型用法代码示例。如果您正苦于以下问题:C++ Channel类的具体用法?C++ Channel怎么用?C++ Channel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Channel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: process
//-------------------------------------------------------------------------------------
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;
}
示例2: charge
//-------------------------------------------------------------------------------------
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);
}
示例3: createAccount
//-------------------------------------------------------------------------------------
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;
}
示例4: onAlloc
//-------------------------------------------------------------------------------------
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));
}
示例5: onReqCreateAccountResult
//-------------------------------------------------------------------------------------
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);
}
示例6: processChannels
//-------------------------------------------------------------------------------------
void NetworkInterface::processChannels(KBEngine::Network::MessageHandlers* pMsgHandlers)
{
ChannelMap::iterator iter = channelMap_.begin();
for(; iter != channelMap_.end(); )
{
Network::Channel* pChannel = iter->second;
if(pChannel->isDestroyed())
{
++iter;
}
else if(pChannel->isCondemn())
{
++iter;
deregisterChannel(pChannel);
pChannel->destroy();
Network::Channel::reclaimPoolObject(pChannel);
}
else
{
pChannel->processPackets(pMsgHandlers);
++iter;
}
}
}
示例7: sendToClient
//-------------------------------------------------------------------------------------
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;
}
示例8: onMessage
//-------------------------------------------------------------------------------------
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);
}
示例9: onAppActiveTick
//-------------------------------------------------------------------------------------
void ServerApp::onAppActiveTick(Network::Channel* pChannel, COMPONENT_TYPE componentType, COMPONENT_ID componentID)
{
if(componentType != CLIENT_TYPE)
if(pChannel->isExternal())
return;
Network::Channel* pTargetChannel = NULL;
if(componentType != CONSOLE_TYPE && componentType != CLIENT_TYPE)
{
Components::ComponentInfos* cinfos =
Components::getSingleton().findComponent(componentType, KBEngine::getUserUID(), componentID);
if(cinfos == NULL || cinfos->pChannel == NULL)
{
ERROR_MSG(fmt::format("ServerApp::onAppActiveTick[{:p}]: {}:{} not found.\n",
(void*)pChannel, COMPONENT_NAME_EX(componentType), componentID));
return;
}
pTargetChannel = cinfos->pChannel;
pTargetChannel->updateLastReceivedTime();
}
else
{
pChannel->updateLastReceivedTime();
pTargetChannel = pChannel;
}
//DEBUG_MSG("ServerApp::onAppActiveTick[%x]: %s:%"PRAppID" lastReceivedTime:%"PRIu64" at %s.\n",
// pChannel, COMPONENT_NAME_EX(componentType), componentID, pChannel->lastReceivedTime(), pTargetChannel->c_str());
}
示例10:
//-------------------------------------------------------------------------------------
InterfacesHandler_Interfaces::~InterfacesHandler_Interfaces()
{
Network::Channel* pInterfacesChannel = Dbmgr::getSingleton().networkInterface().findChannel(g_kbeSrvConfig.interfacesAddr());
if(pInterfacesChannel)
{
pInterfacesChannel->condemn();
}
pInterfacesChannel = NULL;
}
示例11: pushBundle
//-------------------------------------------------------------------------------------
bool Proxy::pushBundle(Network::Bundle* pBundle)
{
if(!clientMailbox())
return false;
Network::Channel* pChannel = clientMailbox()->getChannel();
if(!pChannel)
return false;
pChannel->send(pBundle);
return true;
}
示例12: process
//-------------------------------------------------------------------------------------
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;
}
示例13: onReqCreateAccountResult
//-------------------------------------------------------------------------------------
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);
}
示例14: kick
//-------------------------------------------------------------------------------------
void Proxy::kick()
{
// 如果被销毁频道仍然存活则将其关闭
Network::Channel* pChannel = Baseapp::getSingleton().networkInterface().findChannel(addr_);
if(pChannel && !pChannel->isDestroyed())
{
Network::Bundle* pBundle = Network::Bundle::createPoolObject();
(*pBundle).newMessage(ClientInterface::onKicked);
ClientInterface::onKickedArgs1::staticAddToBundle(*pBundle, SERVER_ERR_PROXY_DESTROYED);
//pBundle->send(Baseapp::getSingleton().networkInterface(), pChannel);
this->sendToClient(ClientInterface::onKicked, pBundle);
this->sendToClient();
pChannel->condemn();
}
}
示例15: eraseClientReq
//-------------------------------------------------------------------------------------
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);
}