included new protocol messages
This commit is contained in:
parent
52210a374d
commit
f41f373ead
1 changed files with 261 additions and 144 deletions
141
src/testbench.h
141
src/testbench.h
|
@ -44,8 +44,17 @@ public:
|
||||||
CTestbench ( QString sNewAddress, quint16 iNewPort ) :
|
CTestbench ( QString sNewAddress, quint16 iNewPort ) :
|
||||||
sAddress ( sNewAddress ), iPort ( iNewPort )
|
sAddress ( sNewAddress ), iPort ( iNewPort )
|
||||||
{
|
{
|
||||||
// bind socket
|
// bind socket (try 100 port numbers)
|
||||||
UdpSocket.bind ( QHostAddress ( QHostAddress::Any ), 22222 );
|
quint16 iPortIncrement = 0; // start value: port nubmer plus ten
|
||||||
|
bool bSuccess = false; // initialization for while loop
|
||||||
|
while ( !bSuccess && ( iPortIncrement <= 100 ) )
|
||||||
|
{
|
||||||
|
bSuccess = UdpSocket.bind (
|
||||||
|
QHostAddress( QHostAddress::Any ),
|
||||||
|
22222 + iPortIncrement );
|
||||||
|
|
||||||
|
iPortIncrement++;
|
||||||
|
}
|
||||||
|
|
||||||
// connect protocol signal
|
// connect protocol signal
|
||||||
QObject::connect ( &Protocol, SIGNAL ( MessReadyForSending ( CVector<uint8_t> ) ),
|
QObject::connect ( &Protocol, SIGNAL ( MessReadyForSending ( CVector<uint8_t> ) ),
|
||||||
|
@ -65,6 +74,17 @@ protected:
|
||||||
( ( static_cast<double> ( iEnd - iStart + 1 ) * rand() ) / RAND_MAX ) );
|
( ( static_cast<double> ( iEnd - iStart + 1 ) * rand() ) / RAND_MAX ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString GenRandomString() const
|
||||||
|
{
|
||||||
|
const int iLen = GenRandomIntInRange ( 0, 111 );
|
||||||
|
QString strReturn = "";
|
||||||
|
for ( int i = 0; i < iLen; i++ )
|
||||||
|
{
|
||||||
|
strReturn += static_cast<char> ( GenRandomIntInRange ( 0, 255 ) );
|
||||||
|
}
|
||||||
|
return strReturn;
|
||||||
|
}
|
||||||
|
|
||||||
QString sAddress;
|
QString sAddress;
|
||||||
quint16 iPort;
|
quint16 iPort;
|
||||||
QTimer Timer;
|
QTimer Timer;
|
||||||
|
@ -74,8 +94,14 @@ protected:
|
||||||
public slots:
|
public slots:
|
||||||
void OnTimer()
|
void OnTimer()
|
||||||
{
|
{
|
||||||
|
CVector<CChannelShortInfo> vecChanInfo ( 1 );
|
||||||
|
CNetworkTransportProps NetTrProps;
|
||||||
|
CServerCoreInfo ServerInfo;
|
||||||
|
CVector<CServerInfo> vecServerInfo ( 1 );
|
||||||
|
CHostAddress CurHostAddress ( QHostAddress ( sAddress ), iPort );
|
||||||
|
|
||||||
// generate random protocol message
|
// generate random protocol message
|
||||||
switch ( GenRandomIntInRange ( 0, 10 ) )
|
switch ( GenRandomIntInRange ( 0, 22 ) )
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
Protocol.CreateJitBufMes ( GenRandomIntInRange ( 0, 10 ) );
|
Protocol.CreateJitBufMes ( GenRandomIntInRange ( 0, 10 ) );
|
||||||
|
@ -91,37 +117,128 @@ public slots:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
Protocol.CreateReqConnClientsList();
|
vecChanInfo[0].iChanID = GenRandomIntInRange ( -2, 20 );
|
||||||
|
vecChanInfo[0].iIpAddr = GenRandomIntInRange ( 0, 100000 );
|
||||||
|
vecChanInfo[0].strName = GenRandomString();
|
||||||
|
|
||||||
|
Protocol.CreateConClientListMes ( vecChanInfo );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
Protocol.CreateChanNameMes ( QString ( "test%1" ).arg (
|
Protocol.CreateReqConnClientsList();
|
||||||
GenRandomIntInRange ( 0, 1000 ) ) );
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5:
|
case 5:
|
||||||
Protocol.CreateChatTextMes ( QString ( "test%1" ).arg (
|
Protocol.CreateChanNameMes ( GenRandomString() );
|
||||||
GenRandomIntInRange ( 0, 1000 ) ) );
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 6:
|
case 6:
|
||||||
Protocol.CreatePingMes ( GenRandomIntInRange ( 0, 100000 ) );
|
Protocol.CreateReqChanNameMes();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 7:
|
case 7:
|
||||||
Protocol.CreateReqNetwTranspPropsMes();
|
Protocol.CreateChatTextMes ( GenRandomString() );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 8:
|
case 8:
|
||||||
|
Protocol.CreatePingMes ( GenRandomIntInRange ( 0, 100000 ) );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 9:
|
||||||
|
NetTrProps.eAudioCodingType =
|
||||||
|
static_cast<EAudComprType> ( GenRandomIntInRange ( 0, 2 ) );
|
||||||
|
|
||||||
|
NetTrProps.iAudioCodingArg = GenRandomIntInRange ( -100, 100 );
|
||||||
|
NetTrProps.iBaseNetworkPacketSize = GenRandomIntInRange ( -2, 1000 );
|
||||||
|
NetTrProps.iBlockSizeFact = GenRandomIntInRange ( -2, 100 );
|
||||||
|
NetTrProps.iNumAudioChannels = GenRandomIntInRange ( -2, 10 );
|
||||||
|
NetTrProps.iSampleRate = GenRandomIntInRange ( -2, 10000 );
|
||||||
|
NetTrProps.iVersion = GenRandomIntInRange ( -2, 10000 );
|
||||||
|
|
||||||
|
Protocol.CreateNetwTranspPropsMes ( NetTrProps );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 10:
|
||||||
|
Protocol.CreateReqNetwTranspPropsMes();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 11:
|
||||||
|
Protocol.CreateCLPingMes ( CurHostAddress,
|
||||||
|
GenRandomIntInRange ( -2, 1000 ) );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 12:
|
||||||
|
Protocol.CreateCLPingWithNumClientsMes ( CurHostAddress,
|
||||||
|
GenRandomIntInRange ( -2, 1000 ),
|
||||||
|
GenRandomIntInRange ( -2, 1000 ) );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 13:
|
||||||
|
Protocol.CreateCLServerFullMes ( CurHostAddress );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 14:
|
||||||
|
ServerInfo.bPermanentOnline =
|
||||||
|
static_cast<bool> ( GenRandomIntInRange ( 0, 1 ) );
|
||||||
|
|
||||||
|
ServerInfo.eCountry =
|
||||||
|
static_cast<QLocale::Country> ( GenRandomIntInRange ( 0, 100 ) );
|
||||||
|
|
||||||
|
ServerInfo.iLocalPortNumber = GenRandomIntInRange ( -2, 10000 );
|
||||||
|
ServerInfo.iMaxNumClients = GenRandomIntInRange ( -2, 10000 );
|
||||||
|
ServerInfo.strCity = GenRandomString();
|
||||||
|
ServerInfo.strName = GenRandomString();
|
||||||
|
ServerInfo.strTopic = GenRandomString();
|
||||||
|
|
||||||
|
Protocol.CreateCLRegisterServerMes ( CurHostAddress,
|
||||||
|
ServerInfo );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 15:
|
||||||
|
Protocol.CreateCLUnregisterServerMes ( CurHostAddress );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 16:
|
||||||
|
vecServerInfo[0].bPermanentOnline =
|
||||||
|
static_cast<bool> ( GenRandomIntInRange ( 0, 1 ) );
|
||||||
|
|
||||||
|
vecServerInfo[0].eCountry =
|
||||||
|
static_cast<QLocale::Country> ( GenRandomIntInRange ( 0, 100 ) );
|
||||||
|
|
||||||
|
vecServerInfo[0].HostAddr = CurHostAddress;
|
||||||
|
vecServerInfo[0].iLocalPortNumber = GenRandomIntInRange ( -2, 10000 );
|
||||||
|
vecServerInfo[0].iMaxNumClients = GenRandomIntInRange ( -2, 10000 );
|
||||||
|
vecServerInfo[0].strCity = GenRandomString();
|
||||||
|
vecServerInfo[0].strName = GenRandomString();
|
||||||
|
vecServerInfo[0].strTopic = GenRandomString();
|
||||||
|
|
||||||
|
Protocol.CreateCLServerListMes ( CurHostAddress,
|
||||||
|
vecServerInfo );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 17:
|
||||||
|
Protocol.CreateCLReqServerListMes ( CurHostAddress );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 18:
|
||||||
|
Protocol.CreateCLSendEmptyMesMes ( CurHostAddress,
|
||||||
|
CurHostAddress );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 19:
|
||||||
|
Protocol.CreateCLEmptyMes ( CurHostAddress );
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 20:
|
||||||
Protocol.CreateAndImmSendAcknMess ( GenRandomIntInRange ( -10, 100 ),
|
Protocol.CreateAndImmSendAcknMess ( GenRandomIntInRange ( -10, 100 ),
|
||||||
GenRandomIntInRange ( -100, 100 ) );
|
GenRandomIntInRange ( -100, 100 ) );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 9:
|
case 21:
|
||||||
Protocol.CreateAndImmSendDisconnectionMes();
|
Protocol.CreateAndImmSendDisconnectionMes();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 10:
|
case 22:
|
||||||
// arbitrary "audio" packet (with random sizes)
|
// arbitrary "audio" packet (with random sizes)
|
||||||
CVector<uint8_t> vecMessage ( GenRandomIntInRange ( 1, 1000 ) );
|
CVector<uint8_t> vecMessage ( GenRandomIntInRange ( 1, 1000 ) );
|
||||||
OnSendProtMessage ( vecMessage );
|
OnSendProtMessage ( vecMessage );
|
||||||
|
|
Loading…
Reference in a new issue