diff options
| author | Crystalwarrior <varsash@gmail.com> | 2020-08-25 12:18:49 +0300 |
|---|---|---|
| committer | Crystalwarrior <varsash@gmail.com> | 2020-08-25 12:18:49 +0300 |
| commit | febfbeafc11ecad57d6e9a06575c28f1b13da8da (patch) | |
| tree | ed3c8bef2b605cbd9caa00c03e7422d362a95d48 /src | |
| parent | f27f210efeb13a5ac29727fef271f8249e3e8c5d (diff) | |
Actually make use of the completely useless CHECK and CH keepalive timer and use them to determine the client's ping.
Display ping in the application window title.
keepalive timer now fires every second instead of every minute
Remove meme clock starting on set_widgets()
implement get_ping() on w_courtroom
Diffstat (limited to 'src')
| -rw-r--r-- | src/courtroom.cpp | 4 | ||||
| -rw-r--r-- | src/packet_distribution.cpp | 10 |
2 files changed, 10 insertions, 4 deletions
diff --git a/src/courtroom.cpp b/src/courtroom.cpp index e2b372c..ec1fc99 100644 --- a/src/courtroom.cpp +++ b/src/courtroom.cpp @@ -8,7 +8,7 @@ Courtroom::Courtroom(AOApplication *p_ao_app) : QMainWindow() qsrand(static_cast<uint>(QDateTime::currentMSecsSinceEpoch() / 1000)); keepalive_timer = new QTimer(this); - keepalive_timer->start(60000); + keepalive_timer->start(1000); chat_tick_timer = new QTimer(this); @@ -623,7 +623,6 @@ void Courtroom::set_widgets() ui_music_display->set_play_once(false); set_size_and_pos(ui_clock, "clock"); - ui_clock->start(30000); if (is_ao2_bg) { set_size_and_pos(ui_ic_chat_message, "ao2_ic_chat_message"); @@ -4672,6 +4671,7 @@ void Courtroom::on_switch_area_music_clicked() void Courtroom::ping_server() { + ping_timer.start(); ao_app->send_server_packet( new AOPacket("CH#" + QString::number(m_cid) + "#%")); } diff --git a/src/packet_distribution.cpp b/src/packet_distribution.cpp index e4e5d5c..9422cfd 100644 --- a/src/packet_distribution.cpp +++ b/src/packet_distribution.cpp @@ -116,7 +116,13 @@ void AOApplication::server_packet_received(AOPacket *p_packet) qDebug() << "R:" << f_packet; #endif - if (header == "decryptor") { + if (header == "CHECK") { + if (courtroom_constructed) { + last_ping = w_courtroom->get_ping(); + w_courtroom->set_window_title(window_title + " [ping:" + QString::number(last_ping) + "]"); + } + } + else if (header == "decryptor") { if (f_contents.size() == 0) goto end; @@ -250,7 +256,7 @@ void AOApplication::server_packet_received(AOPacket *p_packet) courtroom_loaded = false; - QString window_title = tr("Attorney Online 2"); + window_title = tr("Attorney Online 2"); int selected_server = w_lobby->get_selected_server(); QString server_address = "", server_name = ""; |
