added support for server disconnection

This commit is contained in:
Volker Fischer 2015-10-17 15:37:58 +00:00
parent c17413afe3
commit b5bae73ab3
6 changed files with 46 additions and 12 deletions

View file

@ -1,5 +1,6 @@
3.3.10
- added support for server disconnection

View file

@ -211,6 +211,10 @@ QObject::connect ( &Channel, SIGNAL ( OpusSupported() ),
SIGNAL ( CLPingWithNumClientsReceived ( CHostAddress, int, int ) ),
this, SLOT ( OnCLPingWithNumClientsReceived ( CHostAddress, int, int ) ) );
QObject::connect ( &ConnLessProtocol,
SIGNAL ( CLDisconnection ( CHostAddress ) ),
this, SLOT ( OnCLDisconnection ( CHostAddress ) ) );
#ifdef ENABLE_CLIENT_VERSION_AND_OS_DEBUGGING
QObject::connect ( &ConnLessProtocol,
SIGNAL ( CLVersionAndOSReceived ( CHostAddress, COSUtil::EOpSystemType, QString ) ),

View file

@ -399,6 +399,7 @@ public slots:
void OnJittBufSizeChanged ( int iNewJitBufSize );
void OnReqChanInfo() { Channel.SetRemoteInfo ( ChannelInfo ); }
void OnNewConnection();
void OnCLDisconnection ( CHostAddress InetAddr ) { if ( InetAddr == Channel.GetAddress() ) { Stop(); } }
void OnCLPingReceived ( CHostAddress InetAddr,
int iMs );

View file

@ -57,6 +57,7 @@ int main ( int argc, char** argv )
bool bUseGUI = true;
bool bStartMinimized = false;
bool bShowComplRegConnList = false;
bool bDisconnectAllClients = false;
bool bShowAnalyzerConsole = false;
bool bCentServPingServerInList = false;
int iNumServerChannels = DEFAULT_USED_NUM_CHANNELS;
@ -174,6 +175,20 @@ int main ( int argc, char** argv )
}
// Disconnect all clients (emergency mode) -----------------------------
// Undocumented debugging command line argument: Needed to disconnect
// an unwanted client.
if ( GetFlagArgument ( argv,
i,
"--disconnectall", // no short form
"--disconnectall" ) )
{
bDisconnectAllClients = true;
tsConsole << "- disconnect all clients" << endl;
continue;
}
// Show analyzer console -----------------------------------------------
// Undocumented debugging command line argument: Show the analyzer
// console to debug network buffer properties.
@ -448,6 +463,7 @@ int main ( int argc, char** argv )
strServerInfo,
strWelcomeMessage,
bCentServPingServerInList,
bDisconnectAllClients,
eLicenceType );
if ( bUseGUI )

View file

@ -207,6 +207,7 @@ CServer::CServer ( const int iNewMaxNumChan,
const QString& strServerInfo,
const QString& strNewWelcomeMessage,
const bool bNCentServPingServerInList,
const bool bNDisconnectAllClients,
const ELicenceType eNLicenceType ) :
iMaxNumChannels ( iNewMaxNumChan ),
Socket ( this, iPortNumber ),
@ -219,7 +220,8 @@ CServer::CServer ( const int iNewMaxNumChan,
&ConnLessProtocol ),
bAutoRunMinimized ( false ),
strWelcomeMessage ( strNewWelcomeMessage ),
eLicenceType ( eNLicenceType )
eLicenceType ( eNLicenceType ),
bDisconnectAllClients ( bNDisconnectAllClients )
{
int iOpusError;
int i;
@ -560,6 +562,14 @@ void CServer::OnSendProtMessage ( int iChID, CVector<uint8_t> vecMessage )
void CServer::OnNewConnection ( int iChID,
CHostAddress RecHostAddr )
{
// in the special case that all clients shall be disconnected, just send the
// disconnect message and leave this function
if ( bDisconnectAllClients )
{
ConnLessProtocol.CreateCLDisconnection ( RecHostAddr );
return;
}
// on a new connection we query the network transport properties for the
// audio packets (to use the correct network block size and audio
// compression properties, etc.)

View file

@ -131,6 +131,7 @@ public:
const QString& strServerInfo,
const QString& strNewWelcomeMessage,
const bool bNCentServPingServerInList,
const bool bNDisconnectAllClients,
const ELicenceType eNLicenceType );
void Start();
@ -273,6 +274,7 @@ protected:
// messaging
QString strWelcomeMessage;
ELicenceType eLicenceType;
bool bDisconnectAllClients;
signals:
void Started();