本文整理汇总了C++中TcpConnection::getSocket方法的典型用法代码示例。如果您正苦于以下问题:C++ TcpConnection::getSocket方法的具体用法?C++ TcpConnection::getSocket怎么用?C++ TcpConnection::getSocket使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TcpConnection
的用法示例。
在下文中一共展示了TcpConnection::getSocket方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: accept
void TcpServer::accept()
{
TcpConnection* conn = doCreateConnection();
myAcceptor->async_accept(conn->getSocket(), boost::bind(&TcpServer::handleAccept, this, conn, asio::placeholders::error));
}
示例2: innerMsgProcess
bool AppBusiness::innerMsgProcess(TcpConnection& connection,uint32 type,Json::Value &arrayObj,uint32 code) const
{
uint32 err=1;
Json::Value rValue;
Json::Value rData;
uint32 rNo=PROTOCOL_INVALID;
switch(type)
{
case PROTOCOL_CREATE_CHAR_C:
{
rNo=PROTOCOL_CREATE_CHAR_S;
if(code!=ERR_SUCCESS)
{
break;
}
err=ERR_SUCCESS;
}
break;
case PROTOCOL_ENTER_C:
{
uint32 uid = arrayObj["uid"].asUInt();
rNo=PROTOCOL_ENTER_S;
if(code!=ERR_SUCCESS)
{
break;
}
GamePlayer *player = GamePlayerManager::instance().getPlayer(uid);
if(player)
{
err=ERR_EXIST_AL_LOGIN;
break;
}
player=new GamePlayer(connection);
player->init(arrayObj);
GamePlayerManager::instance().AddPlayer(player);
ConnetManager::instance().add(connection.getSocket().getHandle(),player);
player->fillClientData(rData);
err=ERR_SUCCESS;
}
break;
case PROTOCOL_CHAR_LIST_C:
{
rNo=PROTOCOL_CHAR_LIST_S;
if(code==ERR_SUCCESS)
{
rData["uid"]=arrayObj["uid"];
rData["name"]=arrayObj["name"];
rData["role"]=arrayObj["role"];
rData["level"]=arrayObj["level"];
err=ERR_SUCCESS;
}
else
{
err=ERR_CHAR_EXIST;
}
}
break;
default:
return false;
}
rValue["code"]=err;
rValue["type"]=rNo;
rValue["data"]=rData;
string str = rValue.toStyledString();
char buff[MAX_SEND_BUFF];
memset(buff,0,MAX_SEND_BUFF);
uint16 len=str.length()+2;
memcpy(buff,&len,sizeof(uint16));
memcpy(buff+2,str.c_str(),str.length());
LinuxTcpConnection* pp = static_cast<LinuxTcpConnection*> (&connection);
pp->send(buff,len);
// connection.sendBaseBuff(buff,len);
//connection.sendBaseBuff(buff,len);
return true;
}