new command line option -d to disconnect all clients on shutdown of the server (Ticket #161)
This commit is contained in:
parent
34cccac29f
commit
599306156d
4 changed files with 82 additions and 73 deletions
|
@ -21,6 +21,8 @@
|
||||||
|
|
||||||
- new design for the About dialog (Ticket #189)
|
- new design for the About dialog (Ticket #189)
|
||||||
|
|
||||||
|
- new command line option -d to disconnect all clients on shutdown of the server (Ticket #161)
|
||||||
|
|
||||||
- bug fix: for mono capture jack audio interface Jamulus complains it
|
- bug fix: for mono capture jack audio interface Jamulus complains it
|
||||||
cannot make connections (Ticket #137)
|
cannot make connections (Ticket #137)
|
||||||
|
|
||||||
|
|
85
src/main.cpp
85
src/main.cpp
|
@ -51,36 +51,36 @@ int main ( int argc, char** argv )
|
||||||
// arguments
|
// arguments
|
||||||
#if defined( SERVER_BUNDLE ) && ( defined( __APPLE__ ) || defined( __MACOSX ) )
|
#if defined( SERVER_BUNDLE ) && ( defined( __APPLE__ ) || defined( __MACOSX ) )
|
||||||
// if we are on MacOS and we are building a server bundle, starts Jamulus in server mode
|
// if we are on MacOS and we are building a server bundle, starts Jamulus in server mode
|
||||||
bool bIsClient = false;
|
bool bIsClient = false;
|
||||||
#else
|
#else
|
||||||
bool bIsClient = true;
|
bool bIsClient = true;
|
||||||
#endif
|
#endif
|
||||||
bool bUseGUI = true;
|
bool bUseGUI = true;
|
||||||
bool bStartMinimized = false;
|
bool bStartMinimized = false;
|
||||||
bool bShowComplRegConnList = false;
|
bool bShowComplRegConnList = false;
|
||||||
bool bDisconnectAllClients = false;
|
bool bDisconnectAllClientsOnQuit = false;
|
||||||
bool bUseDoubleSystemFrameSize = true; // default is 128 samples frame size
|
bool bUseDoubleSystemFrameSize = true; // default is 128 samples frame size
|
||||||
bool bShowAnalyzerConsole = false;
|
bool bShowAnalyzerConsole = false;
|
||||||
bool bCentServPingServerInList = false;
|
bool bCentServPingServerInList = false;
|
||||||
bool bNoAutoJackConnect = false;
|
bool bNoAutoJackConnect = false;
|
||||||
bool bUseTranslation = true;
|
bool bUseTranslation = true;
|
||||||
bool bCustomPortNumberGiven = false;
|
bool bCustomPortNumberGiven = false;
|
||||||
int iNumServerChannels = DEFAULT_USED_NUM_CHANNELS;
|
int iNumServerChannels = DEFAULT_USED_NUM_CHANNELS;
|
||||||
int iMaxDaysHistory = DEFAULT_DAYS_HISTORY;
|
int iMaxDaysHistory = DEFAULT_DAYS_HISTORY;
|
||||||
int iCtrlMIDIChannel = INVALID_MIDI_CH;
|
int iCtrlMIDIChannel = INVALID_MIDI_CH;
|
||||||
quint16 iPortNumber = LLCON_DEFAULT_PORT_NUMBER;
|
quint16 iPortNumber = LLCON_DEFAULT_PORT_NUMBER;
|
||||||
ELicenceType eLicenceType = LT_NO_LICENCE;
|
ELicenceType eLicenceType = LT_NO_LICENCE;
|
||||||
QString strConnOnStartupAddress = "";
|
QString strConnOnStartupAddress = "";
|
||||||
QString strIniFileName = "";
|
QString strIniFileName = "";
|
||||||
QString strHTMLStatusFileName = "";
|
QString strHTMLStatusFileName = "";
|
||||||
QString strServerName = "";
|
QString strServerName = "";
|
||||||
QString strLoggingFileName = "";
|
QString strLoggingFileName = "";
|
||||||
QString strHistoryFileName = "";
|
QString strHistoryFileName = "";
|
||||||
QString strRecordingDirName = "";
|
QString strRecordingDirName = "";
|
||||||
QString strCentralServer = "";
|
QString strCentralServer = "";
|
||||||
QString strServerInfo = "";
|
QString strServerInfo = "";
|
||||||
QString strWelcomeMessage = "";
|
QString strWelcomeMessage = "";
|
||||||
QString strClientName = APP_NAME;
|
QString strClientName = APP_NAME;
|
||||||
|
|
||||||
// QT docu: argv()[0] is the program name, argv()[1] is the first
|
// QT docu: argv()[0] is the program name, argv()[1] is the first
|
||||||
// argument and argv()[argc()-1] is the last argument.
|
// argument and argv()[argc()-1] is the last argument.
|
||||||
|
@ -200,6 +200,18 @@ int main ( int argc, char** argv )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Disconnect all clients on quit --------------------------------------
|
||||||
|
if ( GetFlagArgument ( argv,
|
||||||
|
i,
|
||||||
|
"-d",
|
||||||
|
"--discononquit" ) )
|
||||||
|
{
|
||||||
|
bDisconnectAllClientsOnQuit = true;
|
||||||
|
tsConsole << "- disconnect all clients on quit" << endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Disabling auto Jack connections -------------------------------------
|
// Disabling auto Jack connections -------------------------------------
|
||||||
if ( GetFlagArgument ( argv,
|
if ( GetFlagArgument ( argv,
|
||||||
i,
|
i,
|
||||||
|
@ -239,20 +251,6 @@ 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 -----------------------------------------------
|
// Show analyzer console -----------------------------------------------
|
||||||
// Undocumented debugging command line argument: Show the analyzer
|
// Undocumented debugging command line argument: Show the analyzer
|
||||||
// console to debug network buffer properties.
|
// console to debug network buffer properties.
|
||||||
|
@ -626,7 +624,7 @@ int main ( int argc, char** argv )
|
||||||
strWelcomeMessage,
|
strWelcomeMessage,
|
||||||
strRecordingDirName,
|
strRecordingDirName,
|
||||||
bCentServPingServerInList,
|
bCentServPingServerInList,
|
||||||
bDisconnectAllClients,
|
bDisconnectAllClientsOnQuit,
|
||||||
bUseDoubleSystemFrameSize,
|
bUseDoubleSystemFrameSize,
|
||||||
eLicenceType );
|
eLicenceType );
|
||||||
if ( bUseGUI )
|
if ( bUseGUI )
|
||||||
|
@ -704,6 +702,7 @@ QString UsageArguments ( char **argv )
|
||||||
" -v, --version output version information and exit\n"
|
" -v, --version output version information and exit\n"
|
||||||
"\nServer only:\n"
|
"\nServer only:\n"
|
||||||
" -a, --servername server name, required for HTML status\n"
|
" -a, --servername server name, required for HTML status\n"
|
||||||
|
" -d, --discononquit disconnect all clients on quit\n"
|
||||||
" -D, --histdays number of days of history to display\n"
|
" -D, --histdays number of days of history to display\n"
|
||||||
" -e, --centralserver address of the central server\n"
|
" -e, --centralserver address of the central server\n"
|
||||||
" -F, --fastupdate use 64 samples frame size mode\n"
|
" -F, --fastupdate use 64 samples frame size mode\n"
|
||||||
|
|
|
@ -231,28 +231,28 @@ CServer::CServer ( const int iNewMaxNumChan,
|
||||||
const QString& strNewWelcomeMessage,
|
const QString& strNewWelcomeMessage,
|
||||||
const QString& strRecordingDirName,
|
const QString& strRecordingDirName,
|
||||||
const bool bNCentServPingServerInList,
|
const bool bNCentServPingServerInList,
|
||||||
const bool bNDisconnectAllClients,
|
const bool bNDisconnectAllClientsOnQuit,
|
||||||
const bool bNUseDoubleSystemFrameSize,
|
const bool bNUseDoubleSystemFrameSize,
|
||||||
const ELicenceType eNLicenceType ) :
|
const ELicenceType eNLicenceType ) :
|
||||||
bUseDoubleSystemFrameSize ( bNUseDoubleSystemFrameSize ),
|
bUseDoubleSystemFrameSize ( bNUseDoubleSystemFrameSize ),
|
||||||
iMaxNumChannels ( iNewMaxNumChan ),
|
iMaxNumChannels ( iNewMaxNumChan ),
|
||||||
Socket ( this, iPortNumber ),
|
Socket ( this, iPortNumber ),
|
||||||
Logging ( iMaxDaysHistory ),
|
Logging ( iMaxDaysHistory ),
|
||||||
JamRecorder ( strRecordingDirName ),
|
JamRecorder ( strRecordingDirName ),
|
||||||
bEnableRecording ( !strRecordingDirName.isEmpty() ),
|
bEnableRecording ( !strRecordingDirName.isEmpty() ),
|
||||||
bWriteStatusHTMLFile ( false ),
|
bWriteStatusHTMLFile ( false ),
|
||||||
HighPrecisionTimer ( bNUseDoubleSystemFrameSize ),
|
HighPrecisionTimer ( bNUseDoubleSystemFrameSize ),
|
||||||
ServerListManager ( iPortNumber,
|
ServerListManager ( iPortNumber,
|
||||||
strCentralServer,
|
strCentralServer,
|
||||||
strServerInfo,
|
strServerInfo,
|
||||||
iNewMaxNumChan,
|
iNewMaxNumChan,
|
||||||
bNCentServPingServerInList,
|
bNCentServPingServerInList,
|
||||||
&ConnLessProtocol ),
|
&ConnLessProtocol ),
|
||||||
bAutoRunMinimized ( false ),
|
bAutoRunMinimized ( false ),
|
||||||
strWelcomeMessage ( strNewWelcomeMessage ),
|
strWelcomeMessage ( strNewWelcomeMessage ),
|
||||||
eLicenceType ( eNLicenceType ),
|
eLicenceType ( eNLicenceType ),
|
||||||
bDisconnectAllClients ( bNDisconnectAllClients ),
|
bDisconnectAllClientsOnQuit ( bNDisconnectAllClientsOnQuit ),
|
||||||
pSignalHandler ( CSignalHandler::getSingletonP() )
|
pSignalHandler ( CSignalHandler::getSingletonP() )
|
||||||
{
|
{
|
||||||
int iOpusError;
|
int iOpusError;
|
||||||
int i;
|
int i;
|
||||||
|
@ -810,14 +810,6 @@ void CServer::SendProtMessage ( int iChID, CVector<uint8_t> vecMessage )
|
||||||
void CServer::OnNewConnection ( int iChID,
|
void CServer::OnNewConnection ( int iChID,
|
||||||
CHostAddress RecHostAddr )
|
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
|
// on a new connection we query the network transport properties for the
|
||||||
// audio packets (to use the correct network block size and audio
|
// audio packets (to use the correct network block size and audio
|
||||||
// compression properties, etc.)
|
// compression properties, etc.)
|
||||||
|
@ -918,6 +910,22 @@ void CServer::OnCLDisconnection ( CHostAddress InetAddr )
|
||||||
|
|
||||||
void CServer::OnAboutToQuit()
|
void CServer::OnAboutToQuit()
|
||||||
{
|
{
|
||||||
|
// if enabled, disconnect all clients on quit
|
||||||
|
if ( bDisconnectAllClientsOnQuit )
|
||||||
|
{
|
||||||
|
Mutex.lock();
|
||||||
|
{
|
||||||
|
for ( int i = 0; i < iMaxNumChannels; i++ )
|
||||||
|
{
|
||||||
|
if ( vecChannels[i].IsConnected() )
|
||||||
|
{
|
||||||
|
ConnLessProtocol.CreateCLDisconnection ( vecChannels[i].GetAddress() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Mutex.unlock(); // release mutex
|
||||||
|
}
|
||||||
|
|
||||||
Stop();
|
Stop();
|
||||||
|
|
||||||
// if server was registered at the central server, unregister on shutdown
|
// if server was registered at the central server, unregister on shutdown
|
||||||
|
|
|
@ -178,7 +178,7 @@ public:
|
||||||
const QString& strNewWelcomeMessage,
|
const QString& strNewWelcomeMessage,
|
||||||
const QString& strRecordingDirName,
|
const QString& strRecordingDirName,
|
||||||
const bool bNCentServPingServerInList,
|
const bool bNCentServPingServerInList,
|
||||||
const bool bNDisconnectAllClients,
|
const bool bNDisconnectAllClientsOnQuit,
|
||||||
const bool bNUseDoubleSystemFrameSize,
|
const bool bNUseDoubleSystemFrameSize,
|
||||||
const ELicenceType eNLicenceType );
|
const ELicenceType eNLicenceType );
|
||||||
|
|
||||||
|
@ -369,7 +369,7 @@ protected:
|
||||||
// messaging
|
// messaging
|
||||||
QString strWelcomeMessage;
|
QString strWelcomeMessage;
|
||||||
ELicenceType eLicenceType;
|
ELicenceType eLicenceType;
|
||||||
bool bDisconnectAllClients;
|
bool bDisconnectAllClientsOnQuit;
|
||||||
|
|
||||||
CSignalHandler* pSignalHandler;
|
CSignalHandler* pSignalHandler;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue