mirror of
https://github.com/edubart/otclient.git
synced 2025-10-21 06:53:27 +02:00
Improve walk when lagging
This commit is contained in:
@@ -125,7 +125,7 @@ void Connection::write(uint8* buffer, size_t size)
|
||||
m_outputStream = std::shared_ptr<asio::streambuf>(new asio::streambuf);
|
||||
|
||||
m_delayedWriteTimer.cancel();
|
||||
m_delayedWriteTimer.expires_from_now(boost::posix_time::milliseconds(1));
|
||||
m_delayedWriteTimer.expires_from_now(boost::posix_time::milliseconds(10));
|
||||
m_delayedWriteTimer.async_wait(std::bind(&Connection::onCanWrite, asConnection(), std::placeholders::_1));
|
||||
}
|
||||
|
||||
@@ -215,6 +215,7 @@ void Connection::onResolve(const boost::system::error_code& error, asio::ip::bas
|
||||
void Connection::onConnect(const boost::system::error_code& error)
|
||||
{
|
||||
m_readTimer.cancel();
|
||||
m_activityTimer.restart();
|
||||
|
||||
if(error == asio::error::operation_aborted)
|
||||
return;
|
||||
@@ -263,6 +264,7 @@ void Connection::onWrite(const boost::system::error_code& error, size_t writeSiz
|
||||
void Connection::onRecv(const boost::system::error_code& error, size_t recvSize)
|
||||
{
|
||||
m_readTimer.cancel();
|
||||
m_activityTimer.restart();
|
||||
|
||||
if(error == asio::error::operation_aborted)
|
||||
return;
|
||||
|
@@ -61,6 +61,7 @@ public:
|
||||
boost::system::error_code getError() { return m_error; }
|
||||
bool isConnecting() { return m_connecting; }
|
||||
bool isConnected() { return m_connected; }
|
||||
ticks_t getElapsedTicksSinceLastRead() { return m_connected ? m_activityTimer.elapsed_millis() : -1; }
|
||||
|
||||
ConnectionPtr asConnection() { return static_self_cast<Connection>(); }
|
||||
|
||||
@@ -91,6 +92,7 @@ protected:
|
||||
bool m_connected;
|
||||
bool m_connecting;
|
||||
boost::system::error_code m_error;
|
||||
stdext::timer m_activityTimer;
|
||||
|
||||
friend class Server;
|
||||
};
|
||||
|
@@ -42,6 +42,8 @@ public:
|
||||
|
||||
bool isConnected();
|
||||
bool isConnecting();
|
||||
ticks_t getElapsedTicksSinceLastRead() { return m_connection ? m_connection->getElapsedTicksSinceLastRead() : -1; }
|
||||
|
||||
ConnectionPtr getConnection() { return m_connection; }
|
||||
void setConnection(const ConnectionPtr& connection) { m_connection = connection; }
|
||||
|
||||
|
Reference in New Issue
Block a user