Skip to content

Commit c40216d

Browse files
committed
fix: wait for ping reply before speaking stats
1 parent d1f0ad5 commit c40216d

2 files changed

Lines changed: 24 additions & 8 deletions

File tree

Client/qtTeamTalk/mainwindow.cpp

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,9 @@ void MainWindow::clienteventCmdProcessing(int cmdid, bool complete)
11581158
case CMD_COMPLETE_LOGIN:
11591159
cmdCompleteLoggedIn(TT_GetMyUserID(ttInst));
11601160
break;
1161+
case CMD_COMPLETE_PING:
1162+
speakClientStats();
1163+
break;
11611164
case CMD_COMPLETE_JOINCHANNEL:
11621165
break;
11631166
case CMD_COMPLETE_LIST_CHANNELBANS:
@@ -8043,13 +8046,24 @@ void MainWindow::closeEvent(QCloseEvent *event)
80438046
#endif
80448047
}
80458048

8046-
void MainWindow::slotSpeakClientStats(bool /*checked = false*/)
8047-
{
8048-
if (TT_GetFlags(ttInst) & CLIENT_CONNECTED)
8049-
TT_DoPing(ttInst);
8050-
8051-
ClientStatistics stats = {};
8052-
TT_GetClientStatistics(ttInst, &stats);
8049+
void MainWindow::slotSpeakClientStats(bool /*checked = false*/)
8050+
{
8051+
if (TT_GetFlags(ttInst) & CLIENT_CONNECTED)
8052+
{
8053+
int cmdid = TT_DoPing(ttInst);
8054+
if (cmdid > 0)
8055+
{
8056+
m_commands.insert(cmdid, CMD_COMPLETE_PING);
8057+
return;
8058+
}
8059+
}
8060+
speakClientStats();
8061+
}
8062+
8063+
void MainWindow::speakClientStats()
8064+
{
8065+
ClientStatistics stats = {};
8066+
TT_GetClientStatistics(ttInst, &stats);
80538067
float rx = float(stats.nUdpBytesRecv - m_clientstats.nUdpBytesRecv);
80548068
float tx = float(stats.nUdpBytesSent - m_clientstats.nUdpBytesSent);
80558069
int ping = stats.nUdpPingTimeMs;

Client/qtTeamTalk/mainwindow.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ enum CommandComplete
5353
CMD_COMPLETE_SUBSCRIBE,
5454
CMD_COMPLETE_UNSUBSCRIBE,
5555

56-
CMD_COMPLETE_SAVECONFIG
56+
CMD_COMPLETE_SAVECONFIG,
57+
CMD_COMPLETE_PING
5758
};
5859

5960
enum TimerEvent
@@ -246,6 +247,7 @@ class MainWindow : public QMainWindow
246247
/* 'mode' is mask of 'AudioStorageMode' */
247248
void updateAudioStorage(bool enable, AudioStorageMode mode);
248249
void updateAudioConfig();
250+
void speakClientStats();
249251
bool sendDesktopWindow();
250252
void restartSendDesktopWindowTimer();
251253
void sendDesktopCursor();

0 commit comments

Comments
 (0)