本文整理汇总了C++中SocketClient::retain方法的典型用法代码示例。如果您正苦于以下问题:C++ SocketClient::retain方法的具体用法?C++ SocketClient::retain怎么用?C++ SocketClient::retain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SocketClient
的用法示例。
在下文中一共展示了SocketClient::retain方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: menuCloseCallback
void MainLayer::menuCloseCallback(Object* pSender)
{
SocketClient* socketClient = SocketClient::createSocketClient("127.0.0.1",12345);
socketClient->retain();
SocketMgr::set(socketClient);
socketClient = SocketMgr::get();
auto callback = std::bind(&MainLayer::onLoginResponse,this,std::placeholders::_1);
socketClient->registCallbackT<LoginResponse>(1,callback);
if (socketClient->connect())
{
LoginRequest* loginRequestMessage = new LoginRequest();
loginRequestMessage->set_username("cmzx3444");
loginRequestMessage->set_password("123456");
socketClient->send(loginRequestMessage);
loginRequestMessage = new LoginRequest();
loginRequestMessage->set_username("cmzx3444");
loginRequestMessage->set_password("123456");
socketClient->send(loginRequestMessage);
loginRequestMessage = new LoginRequest();
loginRequestMessage->set_username("cmzx3444");
loginRequestMessage->set_password("123456");
socketClient->send(loginRequestMessage);
loginRequestMessage = new LoginRequest();
loginRequestMessage->set_username("cmzx3444");
loginRequestMessage->set_password("123456");
socketClient->send(loginRequestMessage);
}
else
{
socketClient->release();
}
Director::getInstance()->end();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
exit(0);
#endif
}