本文整理汇总了C++中OutputMessage_ptr::size方法的典型用法代码示例。如果您正苦于以下问题:C++ OutputMessage_ptr::size方法的具体用法?C++ OutputMessage_ptr::size怎么用?C++ OutputMessage_ptr::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OutputMessage_ptr
的用法示例。
在下文中一共展示了OutputMessage_ptr::size方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: send
bool Connection::send(OutputMessage_ptr msg)
{
#ifdef __DEBUG_NET_DETAIL__
std::clog << "Connection::send init" << std::endl;
#endif
m_connectionLock.lock();
if(m_connectionState != CONNECTION_STATE_OPEN || m_writeError)
{
m_connectionLock.unlock();
return false;
}
TRACK_MESSAGE(msg);
if(!m_pendingWrite)
{
if(msg->getProtocol())
msg->getProtocol()->onSendMessage(msg);
#ifdef __DEBUG_NET_DETAIL__
std::clog << "Connection::send " << msg->size() << std::endl;
#endif
internalSend(msg);
}
else if(m_pendingWrite > 100 && g_config.getBool(ConfigManager::FORCE_CLOSE_SLOW_CONNECTION))
{
std::clog << "NOTICE: Forcing slow connection to disconnect!" << std::endl;
close();
}
else
{
#ifdef __DEBUG_NET__
std::clog << "Connection::send Adding to queue " << msg->size() << std::endl;
#endif
OutputMessagePool::getInstance()->autoSend(msg);
}
m_connectionLock.unlock();
return true;
}
示例2: internalSend
void Connection::internalSend(OutputMessage_ptr msg)
{
TRACK_MESSAGE(msg);
try
{
++m_pendingWrite;
m_writeTimer.expires_from_now(boost::posix_time::seconds(Connection::writeTimeout));
m_writeTimer.async_wait(boost::bind(&Connection::handleWriteTimeout,
boost::weak_ptr<Connection>(shared_from_this()), boost::asio::placeholders::error));
boost::asio::async_write(getHandle(),
boost::asio::buffer(msg->getOutputBuffer(), msg->size()),
boost::bind(&Connection::onWrite, shared_from_this(), msg, boost::asio::placeholders::error));
}
catch(boost::system::system_error& e)
{
if(m_logError)
{
LOG_MESSAGE(LOGTYPE_ERROR, e.what(), "NETWORK");
m_logError = false;
}
}
}
示例3: parsePacket
//.........这里部分代码省略.........
{
addLogLine(LOGTYPE_EVENT, "closing server");
Dispatcher::getInstance().addTask(createTask(boost::bind(
&Game::setGameState, &g_game, GAMESTATE_CLOSED)));
output->put<char>(AP_MSG_COMMAND_OK);
break;
}
case CMD_OPEN_SERVER:
{
addLogLine(LOGTYPE_EVENT, "opening server");
g_game.setGameState(GAMESTATE_NORMAL);
output->put<char>(AP_MSG_COMMAND_OK);
break;
}
case CMD_SHUTDOWN_SERVER:
{
addLogLine(LOGTYPE_EVENT, "shutting down server");
Dispatcher::getInstance().addTask(createTask(boost::bind(
&Game::setGameState, &g_game, GAMESTATE_SHUTDOWN)));
output->put<char>(AP_MSG_COMMAND_OK);
break;
}
case CMD_PAY_HOUSES:
{
Dispatcher::getInstance().addTask(createTask(boost::bind(
&ProtocolAdmin::adminCommandPayHouses, this)));
break;
}
case CMD_RELOAD_SCRIPTS:
{
const int8_t reload = msg.get<char>();
Dispatcher::getInstance().addTask(createTask(boost::bind(
&ProtocolAdmin::adminCommandReload, this, reload)));
break;
}
case CMD_KICK:
{
const std::string param = msg.getString();
Dispatcher::getInstance().addTask(createTask(boost::bind(
&ProtocolAdmin::adminCommandKickPlayer, this, param)));
break;
}
case CMD_SEND_MAIL:
{
const std::string xmlData = msg.getString();
Dispatcher::getInstance().addTask(createTask(boost::bind(
&ProtocolAdmin::adminCommandSendMail, this, xmlData)));
break;
}
case CMD_BROADCAST:
{
const std::string param = msg.getString();
addLogLine(LOGTYPE_EVENT, "broadcasting: " + param);
Dispatcher::getInstance().addTask(createTask(boost::bind(
&Game::broadcastMessage, &g_game, param, MSG_STATUS_WARNING)));
output->put<char>(AP_MSG_COMMAND_OK);
break;
}
default:
{
output->put<char>(AP_MSG_COMMAND_FAILED);
output->putString("not known server command");
addLogLine(LOGTYPE_EVENT, "not known server command");
}
}
break;
}
case AP_MSG_PING:
output->put<char>(AP_MSG_PING_OK);
break;
case AP_MSG_KEEP_ALIVE:
break;
default:
{
output->put<char>(AP_MSG_ERROR);
output->putString("not known command byte");
addLogLine(LOGTYPE_EVENT, "not known command byte");
break;
}
}
if(output->size() > 0)
OutputMessagePool::getInstance()->send(output);
}