Merge pull request #259 from pljones/feature/70-exit-client-cleanly-on-signal
#70 Exit client cleanly on signal
This commit is contained in:
commit
fefd63f271
2 changed files with 34 additions and 1 deletions
|
@ -79,7 +79,8 @@ CClient::CClient ( const quint16 iPortNumber,
|
|||
bJitterBufferOK ( true ),
|
||||
strCentralServerAddress ( "" ),
|
||||
eCentralServerAddressType ( AT_DEFAULT ),
|
||||
iServerSockBufNumFrames ( DEF_NET_BUF_SIZE_NUM_BL )
|
||||
iServerSockBufNumFrames ( DEF_NET_BUF_SIZE_NUM_BL ),
|
||||
pSignalHandler ( CSignalHandler::getSingletonP() )
|
||||
{
|
||||
int iOpusError;
|
||||
|
||||
|
@ -213,6 +214,10 @@ CClient::CClient ( const quint16 iPortNumber,
|
|||
QObject::connect ( &Socket, SIGNAL ( InvalidPacketReceived ( CHostAddress ) ),
|
||||
this, SLOT ( OnInvalidPacketReceived ( CHostAddress ) ) );
|
||||
|
||||
QObject::connect ( pSignalHandler,
|
||||
SIGNAL ( HandledSignal ( int ) ),
|
||||
this, SLOT ( OnHandledSignal ( int ) ) );
|
||||
|
||||
|
||||
// start the socket (it is important to start the socket after all
|
||||
// initializations and connections)
|
||||
|
@ -656,6 +661,28 @@ void CClient::OnCLChannelLevelListReceived ( CHostAddress InetAddr,
|
|||
emit CLChannelLevelListReceived ( InetAddr, vecLevelList );
|
||||
}
|
||||
|
||||
void CClient::OnHandledSignal(int sigNum)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
// Windows does not actually get OnHandledSignal triggered
|
||||
QCoreApplication::instance()->exit();
|
||||
Q_UNUSED ( sigNum )
|
||||
#else
|
||||
switch ( sigNum )
|
||||
{
|
||||
|
||||
case SIGINT:
|
||||
case SIGTERM:
|
||||
// This should trigger OnAboutToQuit
|
||||
QCoreApplication::instance()->exit();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void CClient::Start()
|
||||
{
|
||||
// init object
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "channel.h"
|
||||
#include "util.h"
|
||||
#include "buffer.h"
|
||||
#include "signalhandler.h"
|
||||
#ifdef LLCON_VST_PLUGIN
|
||||
# include "vstsound.h"
|
||||
#else
|
||||
|
@ -389,6 +390,8 @@ protected:
|
|||
// for ping measurement
|
||||
CPreciseTime PreciseTime;
|
||||
|
||||
CSignalHandler* pSignalHandler;
|
||||
|
||||
public slots:
|
||||
void OnSendProtMessage ( CVector<uint8_t> vecMessage );
|
||||
void OnInvalidPacketReceived ( CHostAddress RecHostAddr );
|
||||
|
@ -417,6 +420,9 @@ public slots:
|
|||
void OnCLChannelLevelListReceived ( CHostAddress InetAddr,
|
||||
CVector<uint16_t> vecLevelList );
|
||||
|
||||
private slots:
|
||||
void OnHandledSignal ( int sigNum );
|
||||
|
||||
signals:
|
||||
void ConClientListMesReceived ( CVector<CChannelInfo> vecChanInfo );
|
||||
void ChatTextReceived ( QString strChatText );
|
||||
|
|
Loading…
Reference in a new issue