void Connection::internalSend(OutputMessage_ptr msg) { m_pendingWrite++; boost::asio::async_write(m_socket, boost::asio::buffer(msg->getOutputBuffer(), msg->getMessageLength()), boost::bind(&Connection::onWriteOperation, this, msg, boost::asio::placeholders::error)); }
void Connection::internalSend(const OutputMessage_ptr& msg) { protocol->onSendMessage(msg); try { writeTimer.expires_from_now(boost::posix_time::seconds(Connection::write_timeout)); writeTimer.async_wait(std::bind(&Connection::handleTimeout, std::weak_ptr<Connection>(shared_from_this()), std::placeholders::_1)); boost::asio::async_write(socket, boost::asio::buffer(msg->getOutputBuffer(), msg->getLength()), std::bind(&Connection::onWriteOperation, shared_from_this(), std::placeholders::_1)); } catch (boost::system::system_error& e) { std::cout << "[Network error - Connection::internalSend] " << e.what() << std::endl; close(FORCE_CLOSE); } }
void Connection::internalSend(OutputMessage_ptr msg) { try { ++m_pendingWrite; m_writeTimer.expires_from_now(boost::posix_time::seconds(Connection::write_timeout)); m_writeTimer.async_wait( std::bind(&Connection::handleWriteTimeout, std::weak_ptr<Connection>(shared_from_this()), std::placeholders::_1)); boost::asio::async_write(getHandle(), boost::asio::buffer(msg->getOutputBuffer(), msg->getMessageLength()), std::bind(&Connection::onWriteOperation, shared_from_this(), msg, std::placeholders::_1)); } catch (boost::system::system_error& e) { if (m_logError) { std::cout << "[Network error - Connection::internalSend] " << e.what() << std::endl; m_logError = false; } } }
void Connection::internalSend(OutputMessage_ptr msg) { try { ++m_pendingWrite; m_writeTimer.expires_from_now(boost::posix_time::seconds(Connection::write_timeout)); 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->getMessageLength()), boost::bind(&Connection::onWriteOperation, shared_from_this(), msg, boost::asio::placeholders::error)); } catch (boost::system::system_error& e) { if (m_logError) { LOG_MESSAGE("NETWORK", LOGTYPE_ERROR, 1, e.what()); m_logError = false; } } }
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(std::exception& e) { if(m_logError) { LOG_MESSAGE(LOGTYPE_ERROR, e.what(), "NETWORK"); m_logError = false; } } }