Skip to content

Commit 7ad1d1f

Browse files
committed
Add message context parameter for CLM_TCP_SUPPORTED
1 parent da4162a commit 7ad1d1f

File tree

9 files changed

+56
-22
lines changed

9 files changed

+56
-22
lines changed

src/client.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ protected slots:
477477

478478
void CLRedServerListReceived ( CHostAddress InetAddr, CVector<CServerInfo> vecServerInfo );
479479

480-
void CLTcpSupported ( CHostAddress InetAddr );
480+
void CLTcpSupported ( CHostAddress InetAddr, int iID );
481481

482482
void CLConnClientsListMesReceived ( CHostAddress InetAddr, CVector<CChannelInfo> vecChanInfo );
483483

src/clientdlg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ public slots:
223223
ConnectDlg.SetServerList ( InetAddr, vecServerInfo, true );
224224
}
225225

226-
void OnCLTcpSupported ( CHostAddress InetAddr ) { ConnectDlg.SetTcpSupported ( InetAddr ); }
226+
void OnCLTcpSupported ( CHostAddress InetAddr, int iID ) { ConnectDlg.SetTcpSupported ( InetAddr, iID ); }
227227

228228
void OnCLConnClientsListMesReceived ( CHostAddress InetAddr, CVector<CChannelInfo> vecChanInfo )
229229
{

src/connectdlg.cpp

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -544,16 +544,27 @@ void CConnectDlg::SetServerList ( const CHostAddress& InetAddr, const CVector<CS
544544
TimerPing.start ( PING_UPDATE_TIME_SERVER_LIST_MS );
545545
}
546546

547-
void CConnectDlg::SetTcpSupported ( const CHostAddress& InetAddr )
547+
void CConnectDlg::SetTcpSupported ( const CHostAddress& InetAddr, int iID )
548548
{
549-
qDebug() << "- TCP supported at server" << InetAddr.toString();
549+
qDebug() << "- TCP supported at server" << InetAddr.toString() << "for ID =" << iID;
550550

551-
// if we haven't received the serverlist, it must have got lost due to fragmentation
552-
// retry using TCP instead
553-
if ( !bServerListReceived )
551+
switch ( iID )
554552
{
555-
// send the request for the server list
556-
emit ReqServerListQuery ( InetAddr, true ); // TCP
553+
case PROTMESSID_CLM_SERVER_LIST:
554+
// if we haven't received the serverlist, it must have got lost due to fragmentation
555+
// retry using TCP instead
556+
if ( !bServerListReceived )
557+
{
558+
// send the request for the server list
559+
emit ReqServerListQuery ( InetAddr, true ); // TCP
560+
}
561+
break;
562+
563+
case PROTMESSID_CLM_CONN_CLIENTS_LIST:
564+
break;
565+
566+
default:
567+
break;
557568
}
558569
}
559570

src/connectdlg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class CConnectDlg : public CBaseDlg, private Ui_CConnectDlgBase
6969

7070
void SetServerList ( const CHostAddress& InetAddr, const CVector<CServerInfo>& vecServerInfo, const bool bIsReducedServerList = false );
7171

72-
void SetTcpSupported ( const CHostAddress& InetAddr );
72+
void SetTcpSupported ( const CHostAddress& InetAddr, int iID );
7373

7474
void SetConnClientsList ( const CHostAddress& InetAddr, const CVector<CChannelInfo>& vecChanInfo );
7575

src/protocol.cpp

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,14 @@ CONNECTION LESS MESSAGES
436436
437437
- PROTMESSID_CLM_TCP_SUPPORTED: TCP supported message
438438
439-
note: does not have any data -> n = 0
439+
+----------------------------------------------------------+
440+
| 2 bytes ID of message to be potentially retried over TCP |
441+
+----------------------------------------------------------+
442+
443+
the ID indicates which type of message preceded it:
444+
- PROTMESSID_CLM_SERVER_LIST
445+
- PROTMESSID_CLM_CONN_CLIENTS_LIST
446+
- 0 (sent on new incoming audio stream)
440447
441448
*/
442449

@@ -931,7 +938,7 @@ void CProtocol::ParseConnectionLessMessageBody ( const CVector<uint8_t>& vecbyMe
931938
break;
932939

933940
case PROTMESSID_CLM_TCP_SUPPORTED:
934-
EvaluateCLTcpSupportedMes ( InetAddr );
941+
EvaluateCLTcpSupportedMes ( InetAddr, vecbyMesBodyData );
935942
break;
936943
}
937944
}
@@ -2596,15 +2603,31 @@ bool CProtocol::EvaluateCLRegisterServerResp ( const CHostAddress& InetAddr, con
25962603
return false; // no error
25972604
}
25982605

2599-
void CProtocol::CreateCLTcpSupportedMes ( const CHostAddress& InetAddr )
2606+
void CProtocol::CreateCLTcpSupportedMes ( const CHostAddress& InetAddr, const int iID )
26002607
{
2601-
CreateAndImmSendConLessMessage ( PROTMESSID_CLM_TCP_SUPPORTED, CVector<uint8_t> ( 0 ), InetAddr );
2608+
int iPos = 0; // init position pointer
2609+
2610+
// build data vector (2 bytes long)
2611+
CVector<uint8_t> vecData ( 2 );
2612+
2613+
// message ID just sent (2 bytes)
2614+
PutValOnStream ( vecData, iPos, static_cast<uint32_t> ( iID ), 2 );
2615+
2616+
CreateAndImmSendConLessMessage ( PROTMESSID_CLM_TCP_SUPPORTED, vecData, InetAddr );
26022617
}
26032618

2604-
bool CProtocol::EvaluateCLTcpSupportedMes ( const CHostAddress& InetAddr )
2619+
bool CProtocol::EvaluateCLTcpSupportedMes ( const CHostAddress& InetAddr, const CVector<uint8_t>& vecData )
26052620
{
2621+
int iPos = 0; // init position pointer
2622+
2623+
// check size
2624+
if ( vecData.Size() != 2 )
2625+
{
2626+
return true; // return error code
2627+
}
2628+
26062629
// invoke message action
2607-
emit CLTcpSupported ( InetAddr );
2630+
emit CLTcpSupported ( InetAddr, static_cast<int> ( GetValFromStream ( vecData, iPos, 2 ) ) );
26082631

26092632
return false; // no error
26102633
}

src/protocol.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ class CProtocol : public QObject
155155
void CreateCLReqConnClientsListMes ( const CHostAddress& InetAddr, bool bUseTcpClient );
156156
void CreateCLChannelLevelListMes ( const CHostAddress& InetAddr, const CVector<uint16_t>& vecLevelList, const int iNumClients );
157157
void CreateCLRegisterServerResp ( const CHostAddress& InetAddr, const ESvrRegResult eResult );
158-
void CreateCLTcpSupportedMes ( const CHostAddress& InetAddr );
158+
void CreateCLTcpSupportedMes ( const CHostAddress& InetAddr, const int iID );
159159

160160
static int GetBodyLength ( const CVector<uint8_t>& vecbyData );
161161

@@ -291,7 +291,7 @@ class CProtocol : public QObject
291291
bool EvaluateCLReqConnClientsListMes ( const CHostAddress& InetAddr, CTcpConnection* pTcpConnection );
292292
bool EvaluateCLChannelLevelListMes ( const CHostAddress& InetAddr, const CVector<uint8_t>& vecData );
293293
bool EvaluateCLRegisterServerResp ( const CHostAddress& InetAddr, const CVector<uint8_t>& vecData );
294-
bool EvaluateCLTcpSupportedMes ( const CHostAddress& InetAddr );
294+
bool EvaluateCLTcpSupportedMes ( const CHostAddress& InetAddr, const CVector<uint8_t>& vecData );
295295

296296
int iOldRecID;
297297
int iOldRecCnt;
@@ -358,5 +358,5 @@ public slots:
358358
void CLReqConnClientsList ( CHostAddress InetAddr, CTcpConnection* pTcpConnection );
359359
void CLChannelLevelListReceived ( CHostAddress InetAddr, CVector<uint16_t> vecLevelList );
360360
void CLRegisterServerResp ( CHostAddress InetAddr, ESvrRegResult eStatus );
361-
void CLTcpSupported ( CHostAddress InetAddr );
361+
void CLTcpSupported ( CHostAddress InetAddr, int iID );
362362
};

src/server.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ void CServer::OnNewConnection ( int iChID, int iTotChans, CHostAddress RecHostAd
390390
// if TCP is enabled, we need to announce this first, before sending Client ID
391391
if ( bEnableTcp )
392392
{
393-
ConnLessProtocol.CreateCLTcpSupportedMes ( vecChannels[iChID].GetAddress() );
393+
ConnLessProtocol.CreateCLTcpSupportedMes ( vecChannels[iChID].GetAddress(), 0 );
394394
}
395395

396396
// inform the client about its own ID at the server (note that this

src/server.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ public slots:
374374
// if TCP is enabled but this request is on UDP, say TCP is supported
375375
if ( bEnableTcp && !pTcpConnection )
376376
{
377-
ConnLessProtocol.CreateCLTcpSupportedMes ( InetAddr );
377+
ConnLessProtocol.CreateCLTcpSupportedMes ( InetAddr, PROTMESSID_CLM_CONN_CLIENTS_LIST );
378378
}
379379
}
380380

src/serverlist.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ void CServerListManager::RetrieveAll ( const CHostAddress& InetAddr, CTcpConnect
736736
// if TCP is enabled but this request is on UDP, say TCP is supported
737737
if ( bEnableTcp && !pTcpConnection )
738738
{
739-
pConnLessProtocol->CreateCLTcpSupportedMes ( InetAddr );
739+
pConnLessProtocol->CreateCLTcpSupportedMes ( InetAddr, PROTMESSID_CLM_SERVER_LIST );
740740
}
741741
}
742742
}

0 commit comments

Comments
 (0)