@@ -222,7 +222,7 @@ namespace sio
222
222
} else {
223
223
ss<<uo.get_host ();
224
224
}
225
- ss<<" :" <<uo.get_port ()<<" /socket.io/?EIO=3 &transport=websocket" ;
225
+ ss<<" :" <<uo.get_port ()<<" /socket.io/?EIO=4 &transport=websocket" ;
226
226
if (m_sid.size ()>0 ){
227
227
ss<<" &sid=" <<m_sid;
228
228
}
@@ -295,12 +295,6 @@ namespace sio
295
295
lib::error_code ec;
296
296
this ->m_client .send (this ->m_con , *payload, frame::opcode::text, ec);
297
297
});
298
- if (m_ping_timer)
299
- {
300
- asio::error_code e_code;
301
- m_ping_timer->expires_from_now (milliseconds (m_ping_interval), e_code);
302
- m_ping_timer->async_wait (std::bind (&client_impl::ping,this , std::placeholders::_1));
303
- }
304
298
if (!m_ping_timeout_timer)
305
299
{
306
300
m_ping_timeout_timer.reset (new asio::steady_timer (m_client.get_io_service ()));
@@ -497,21 +491,21 @@ namespace sio
497
491
m_ping_timeout = 60000 ;
498
492
}
499
493
500
- m_ping_timer.reset (new asio::steady_timer (m_client.get_io_service ()));
501
- asio::error_code ec;
502
- m_ping_timer->expires_from_now (milliseconds (m_ping_interval), ec);
503
- if (ec)LOG (" ec:" <<ec.message ()<<endl){};
504
- m_ping_timer->async_wait (std::bind (&client_impl::ping,this , std::placeholders::_1));
505
- LOG (" On handshake,sid:" <<m_sid<<" ,ping interval:" <<m_ping_interval<<" ,ping timeout" <<m_ping_timeout<<endl);
506
494
return ;
507
495
}
508
496
failed:
509
497
// just close it.
510
498
m_client.get_io_service ().dispatch (std::bind (&client_impl::close_impl, this ,close ::status::policy_violation," Handshake error" ));
511
499
}
512
500
513
- void client_impl::on_pong ()
501
+ void client_impl::on_ping ()
514
502
{
503
+ packet p (packet::frame_pong);
504
+ m_packet_mgr.encode (p, [&](bool /* isBin*/ ,shared_ptr<const string> payload)
505
+ {
506
+ this ->m_client .send (this ->m_con , *payload, frame::opcode::text);
507
+ });
508
+
515
509
if (m_ping_timeout_timer)
516
510
{
517
511
m_ping_timeout_timer->cancel ();
@@ -536,8 +530,8 @@ namespace sio
536
530
// FIXME how to deal?
537
531
this ->close_impl (close ::status::abnormal_close, " End by server" );
538
532
break ;
539
- case packet::frame_pong :
540
- this ->on_pong ();
533
+ case packet::frame_ping :
534
+ this ->on_ping ();
541
535
break ;
542
536
543
537
default :
@@ -560,11 +554,6 @@ namespace sio
560
554
m_ping_timeout_timer->cancel (ec);
561
555
m_ping_timeout_timer.reset ();
562
556
}
563
- if (m_ping_timer)
564
- {
565
- m_ping_timer->cancel (ec);
566
- m_ping_timer.reset ();
567
- }
568
557
}
569
558
570
559
void client_impl::reset_states ()
0 commit comments