File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -88,7 +88,6 @@ void Client::read() {
8888 s.removeClient (*this );
8989 }
9090 if (!wk.expired ()) {
91- updateTimer ();
9291 read ();
9392 }
9493 }
@@ -103,6 +102,7 @@ void Client::onPacket(SValue p) {
103102 } else {
104103 responseQueue.front ()->onResult (std::move (p));
105104 responseQueue.pop_front ();
105+ updateTimer (true );
106106 }
107107 } else {
108108 login = std::get<std::string>(p);
@@ -178,7 +178,7 @@ void Client::send() {
178178 }
179179 })
180180 );
181- updateTimer ();
181+ updateTimer (false );
182182}
183183
184184void Client::enqueueActionGroup (std::vector<SharedAction> actions) {
@@ -191,10 +191,10 @@ size_t Client::countPending() const {
191191 return sendQueueTotal + responseQueue.size ();
192192}
193193
194- void Client::updateTimer () {
194+ void Client::updateTimer (bool restart ) {
195195 if (sendQueue.empty () && responseQueue.empty ()) {
196196 responseTimer.reset ();
197- } else {
197+ } else if (restart || !responseTimer) {
198198 responseTimer = std::make_shared<boost::asio::steady_timer>(s.io .io );
199199 responseTimer->expires_after (timeout ());
200200 responseTimer->async_wait (makeWeakCallback (responseTimer, [this ](const boost::system::error_code&) {
Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ struct Client : std::enable_shared_from_this<Client> {
3636 void onPacket (SValue);
3737 void read ();
3838 void send ();
39- void updateTimer ();
39+ void updateTimer (bool restart );
4040public:
4141 ~Client ();
4242 Client (Server &s, boost::asio::ip::tcp::socket socket);
You can’t perform that action at this time.
0 commit comments