本文整理汇总了C++中network::Channel类的典型用法代码示例。如果您正苦于以下问题:C++ Channel类的具体用法?C++ Channel怎么用?C++ Channel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Channel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:waluoo,项目名称:kbengine,代码行数:33,代码来源:entity_autoloader.cpp
示例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);
}
开发者ID:hyperfact,项目名称:kbengine,代码行数:35,代码来源:interfaces_handler.cpp
示例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;
}
开发者ID:hyperfact,项目名称:kbengine,代码行数:26,代码来源:interfaces_handler.cpp
示例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));
}
开发者ID:1564143452,项目名称:kbengine,代码行数:29,代码来源:idallocate.cpp
示例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);
}
开发者ID:TimurTarasenko,项目名称:kbengine,代码行数:32,代码来源:loginapp.cpp
示例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;
}
}
}
开发者ID:aabbox,项目名称:kbengine,代码行数:27,代码来源:network_interface.cpp
示例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;
}
开发者ID:JustDo1989,项目名称:kbengine,代码行数:27,代码来源:proxy.cpp
示例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);
}
开发者ID:aabbox,项目名称:kbengine,代码行数:32,代码来源:logwatcher.cpp
示例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());
}
开发者ID:nagisun,项目名称:kbengine,代码行数:33,代码来源:serverapp.cpp
示例10:
//-------------------------------------------------------------------------------------
InterfacesHandler_Interfaces::~InterfacesHandler_Interfaces()
{
Network::Channel* pInterfacesChannel = Dbmgr::getSingleton().networkInterface().findChannel(g_kbeSrvConfig.interfacesAddr());
if(pInterfacesChannel)
{
pInterfacesChannel->condemn();
}
pInterfacesChannel = NULL;
}
开发者ID:hyperfact,项目名称:kbengine,代码行数:11,代码来源:interfaces_handler.cpp
示例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;
}
开发者ID:JustDo1989,项目名称:kbengine,代码行数:13,代码来源:proxy.cpp
示例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;
}
开发者ID:AddictXQ,项目名称:kbengine,代码行数:53,代码来源:sync_entitystreamtemplate_handler.cpp
示例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);
}
开发者ID:1564143452,项目名称:kbengine,代码行数:50,代码来源:loginapp.cpp
示例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();
}
}
开发者ID:,项目名称:,代码行数:16,代码来源:
示例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);
}
开发者ID:hyperfact,项目名称:kbengine,代码行数:18,代码来源:interfaces_handler.cpp
示例16: c_str
//-------------------------------------------------------------------------------------
void EntityMailbox::c_str(char* s, size_t size)
{
const char * mailboxName =
(type_ == MAILBOX_TYPE_CELL) ? "Cell" :
(type_ == MAILBOX_TYPE_BASE) ? "Base" :
(type_ == MAILBOX_TYPE_CLIENT) ? "Client" :
(type_ == MAILBOX_TYPE_BASE_VIA_CELL) ? "BaseViaCell" :
(type_ == MAILBOX_TYPE_CLIENT_VIA_CELL) ? "ClientViaCell" :
(type_ == MAILBOX_TYPE_CELL_VIA_BASE) ? "CellViaBase" :
(type_ == MAILBOX_TYPE_CLIENT_VIA_BASE) ? "ClientViaBase" : "???";
Network::Channel* pChannel = getChannel();
kbe_snprintf(s, size, "%s id:%d, utype:%u, component=%s[%" PRIu64 "], addr: %s.",
mailboxName, id_, utype_,
COMPONENT_NAME_EX(ENTITY_MAILBOX_COMPONENT_TYPE_MAPPING[type_]),
componentID_, (pChannel && pChannel->pEndPoint()) ? pChannel->addr().c_str() : "None");
}
开发者ID:AllenWangxiao,项目名称:kbengine,代码行数:19,代码来源:entity_mailbox.cpp
示例17:
//-------------------------------------------------------------------------------------
Proxy::~Proxy()
{
Baseapp::getSingleton().decProxicesCount();
// 如果被销毁频道仍然存活则将其关闭
Network::Channel* pChannel = Baseapp::getSingleton().networkInterface().findChannel(addr_);
if(pChannel && !pChannel->isDestroyed())
{
Network::Bundle* pBundle = Network::Bundle::ObjPool().createObject();
(*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();
}
SAFE_RELEASE(pProxyForwarder_);
}
开发者ID:JustDo1989,项目名称:kbengine,代码行数:20,代码来源:proxy.cpp
示例18: postMail
//-------------------------------------------------------------------------------------
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;
}
开发者ID:ArcherPeng,项目名称:kbengine-cocos2dx,代码行数:20,代码来源:entitymailboxabstract.cpp
示例19: accountLoginResponse
//-------------------------------------------------------------------------------------
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;
}
开发者ID:aabbox,项目名称:kbengine,代码行数:44,代码来源:interfaces.cpp
示例20: onDataChanged
//-------------------------------------------------------------------------------------
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::ObjPool().createObject();
(*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;
(*pBundle).send(lpChannel->networkInterface(), lpChannel);
Network::Bundle::ObjPool().reclaimObject(pBundle);
}
}
开发者ID:Anehta,项目名称:kbengine,代码行数:43,代码来源:globaldata_client.cpp
注:本文中的network::Channel类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论