1 |
// qsamplerMainForm.cpp |
// qsamplerMainForm.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2019, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2020, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
Copyright (C) 2007,2008,2015 Christian Schoenebeck |
Copyright (C) 2007-2019 Christian Schoenebeck |
6 |
|
|
7 |
This program is free software; you can redistribute it and/or |
This program is free software; you can redistribute it and/or |
8 |
modify it under the terms of the GNU General Public License |
modify it under the terms of the GNU General Public License |
2793 |
} |
} |
2794 |
} |
} |
2795 |
|
|
2796 |
#if CONFIG_LSCP_CLIENT_CONNECTION_LOST |
#if CONFIG_LSCP_CLIENT_CONNECTION_LOST |
2797 |
// If we lost connection to server: Try to automatically reconnect if we |
// If we lost connection to server: Try to automatically reconnect if we |
2798 |
// did not start the server. |
// did not start the server. |
2799 |
// |
// |
2802 |
// restart the server. |
// restart the server. |
2803 |
if (lscp_client_connection_lost(m_pClient) && !m_pServer) |
if (lscp_client_connection_lost(m_pClient) && !m_pServer) |
2804 |
startAutoReconnectClient(); |
startAutoReconnectClient(); |
2805 |
#endif // CONFIG_LSCP_CLIENT_CONNECTION_LOST |
#endif // CONFIG_LSCP_CLIENT_CONNECTION_LOST |
2806 |
} |
} |
2807 |
|
|
2808 |
// Register the next timer slot. |
// Register the next timer slot. |
3024 |
if ((m_pServer && m_pServer->state() == QProcess::Running) |
if ((m_pServer && m_pServer->state() == QProcess::Running) |
3025 |
|| !m_pOptions->bServerStart || bReconnectOnly) |
|| !m_pOptions->bServerStart || bReconnectOnly) |
3026 |
{ |
{ |
3027 |
// if this method is called from doAutoReconnect() then don't bother |
// if this method is called from autoReconnectClient() |
3028 |
// user with an error message |
// then don't bother user with an error message... |
3029 |
if (!bReconnectOnly) { |
if (!bReconnectOnly) { |
3030 |
appendMessagesError( |
appendMessagesError( |
3031 |
tr("Could not connect to server as client.\n\nSorry.") |
tr("Could not connect to server as client.\n\nSorry.") |
3158 |
stabilizeForm(); |
stabilizeForm(); |
3159 |
} |
} |
3160 |
|
|
3161 |
void MainForm::startAutoReconnectClient() { |
|
3162 |
|
void MainForm::startAutoReconnectClient (void) |
3163 |
|
{ |
3164 |
stopClient(); |
stopClient(); |
3165 |
appendMessages("Trying to reconnect."); |
appendMessages(tr("Trying to reconnect...")); |
3166 |
QTimer::singleShot(QSAMPLER_TIMER_MSECS, this, SLOT(doAutoReconnectClient())); |
QTimer::singleShot(QSAMPLER_TIMER_MSECS, this, SLOT(autoReconnectClient())); |
3167 |
} |
} |
3168 |
|
|
3169 |
void MainForm::doAutoReconnectClient() { |
|
3170 |
bool success = startClient(true); |
void MainForm::autoReconnectClient (void) |
3171 |
if (!success) |
{ |
3172 |
QTimer::singleShot(QSAMPLER_TIMER_MSECS, this, SLOT(doAutoReconnectClient())); |
const bool bSuccess = startClient(true); |
3173 |
|
if (!bSuccess) |
3174 |
|
QTimer::singleShot(QSAMPLER_TIMER_MSECS, this, SLOT(autoReconnectClient())); |
3175 |
} |
} |
3176 |
|
|
3177 |
|
|