本文整理汇总了C++中mercury::EndPoint::convertAddress方法的典型用法代码示例。如果您正苦于以下问题:C++ EndPoint::convertAddress方法的具体用法?C++ EndPoint::convertAddress怎么用?C++ EndPoint::convertAddress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mercury::EndPoint
的用法示例。
在下文中一共展示了EndPoint::convertAddress方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initBaseappChannel
//-------------------------------------------------------------------------------------
Mercury::Channel* ClientObjectBase::initBaseappChannel()
{
Mercury::EndPoint* pEndpoint = new Mercury::EndPoint();
pEndpoint->socket(SOCK_STREAM);
if (!pEndpoint->good())
{
ERROR_MSG("ClientObjectBase::initBaseappChannel: couldn't create a socket\n");
delete pEndpoint;
return false;
}
u_int32_t address;
pEndpoint->convertAddress(ip_.c_str(), address);
if(pEndpoint->connect(htons(port_), address) == -1)
{
ERROR_MSG(boost::format("ClientObjectBase::initBaseappChannel: connect server is error(%1%)!\n") %
kbe_strerror());
delete pEndpoint;
return NULL;
}
Mercury::Address addr(ip_.c_str(), port_);
pEndpoint->addr(addr);
pServerChannel_->endpoint(pEndpoint);
pEndpoint->setnonblocking(true);
pEndpoint->setnodelay(true);
connectedGateway_ = true;
return pServerChannel_;
}
示例2: initLoginappChannel
//-------------------------------------------------------------------------------------
Mercury::Channel* ClientObjectBase::initLoginappChannel(std::string accountName, std::string passwd, std::string ip, KBEngine::uint32 port)
{
Mercury::EndPoint* pEndpoint = new Mercury::EndPoint();
pEndpoint->socket(SOCK_STREAM);
if (!pEndpoint->good())
{
ERROR_MSG("ClientObjectBase::initLoginappChannel: couldn't create a socket\n");
delete pEndpoint;
return NULL;
}
u_int32_t address;
pEndpoint->convertAddress(ip.c_str(), address);
if(pEndpoint->connect(htons(port), address) == -1)
{
ERROR_MSG(boost::format("ClientObjectBase::initLoginappChannel: connect server is error(%1%)!\n") %
kbe_strerror());
delete pEndpoint;
return NULL;
}
Mercury::Address addr(ip.c_str(), port);
pEndpoint->addr(addr);
pServerChannel_->endpoint(pEndpoint);
pEndpoint->setnonblocking(true);
pEndpoint->setnodelay(true);
password_ = passwd;
name_ = accountName;
return pServerChannel_;
}
示例3: initCreate
//-------------------------------------------------------------------------------------
bool ClientObject::initCreate()
{
Mercury::EndPoint* pEndpoint = new Mercury::EndPoint();
pEndpoint->socket(SOCK_STREAM);
if (!pEndpoint->good())
{
ERROR_MSG("ClientObject::initNetwork: couldn't create a socket\n");
delete pEndpoint;
error_ = C_ERROR_INIT_NETWORK_FAILED;
return false;
}
ENGINE_COMPONENT_INFO& infos = g_kbeSrvConfig.getBots();
u_int32_t address;
pEndpoint->convertAddress(infos.login_ip, address);
if(pEndpoint->connect(htons(infos.login_port), address) == -1)
{
ERROR_MSG(boost::format("ClientObject::initNetwork(%2%): connect server(%3%:%4%) is error(%1%)!\n") %
kbe_strerror() % name_ % infos.login_ip % infos.login_port);
delete pEndpoint;
// error_ = C_ERROR_INIT_NETWORK_FAILED;
state_ = C_STATE_INIT;
return false;
}
Mercury::Address addr(infos.login_ip, infos.login_port);
pEndpoint->addr(addr);
pServerChannel_->endpoint(pEndpoint);
pEndpoint->setnonblocking(true);
pEndpoint->setnodelay(true);
pServerChannel_->pMsgHandlers(&ClientInterface::messageHandlers);
Bots::getSingleton().pEventPoller()->registerForRead((*pEndpoint), this);
Mercury::Bundle* pBundle = Mercury::Bundle::ObjPool().createObject();
(*pBundle).newMessage(LoginappInterface::hello);
(*pBundle) << KBEVersion::versionString() << KBEVersion::scriptVersionString();
if(Mercury::g_channelExternalEncryptType == 1)
{
pBlowfishFilter_ = new Mercury::BlowfishFilter();
(*pBundle).appendBlob(pBlowfishFilter_->key());
}
else
{
std::string key = "";
(*pBundle).appendBlob(key);
}
pServerChannel_->pushBundle(pBundle);
this->pEndpoint_ = pEndpoint;
return true;
}
示例4: initLoginGateWay
//-------------------------------------------------------------------------------------
bool ClientObject::initLoginGateWay()
{
Bots::getSingleton().pEventPoller()->deregisterForRead(*pServerChannel_->endpoint());
Mercury::EndPoint* pEndpoint = new Mercury::EndPoint();
pEndpoint->socket(SOCK_STREAM);
if (!pEndpoint->good())
{
ERROR_MSG("ClientObject::initLogin: couldn't create a socket\n");
delete pEndpoint;
error_ = C_ERROR_INIT_NETWORK_FAILED;
return false;
}
u_int32_t address;
pEndpoint->convertAddress(ip_.c_str(), address);
if(pEndpoint->connect(htons(port_), address) == -1)
{
ERROR_MSG(boost::format("ClientObject::initLogin(%2%): connect server is error(%1%)!\n") %
kbe_strerror() % name_);
delete pEndpoint;
// error_ = C_ERROR_INIT_NETWORK_FAILED;
state_ = C_STATE_LOGIN_GATEWAY_CREATE;
return false;
}
Mercury::Address addr(ip_.c_str(), port_);
pEndpoint->addr(addr);
pServerChannel_->endpoint(pEndpoint);
pEndpoint->setnonblocking(true);
pEndpoint->setnodelay(true);
Bots::getSingleton().pEventPoller()->registerForRead((*pEndpoint), this);
connectedGateway_ = true;
Mercury::Bundle* pBundle = Mercury::Bundle::ObjPool().createObject();
(*pBundle).newMessage(BaseappInterface::hello);
(*pBundle) << KBEVersion::versionString() << KBEVersion::scriptVersionString();
if(Mercury::g_channelExternalEncryptType == 1)
{
pBlowfishFilter_ = new Mercury::BlowfishFilter();
(*pBundle).appendBlob(pBlowfishFilter_->key());
pServerChannel_->pFilter(NULL);
}
else
{
std::string key = "";
(*pBundle).appendBlob(key);
}
pServerChannel_->pushBundle(pBundle);
return true;
}