refactor: ClientApp / ServerApp, remove do nothing updateStatus methods and calls
This commit is contained in:
parent
b2eb3a036d
commit
ff1e7f3c9f
4 changed files with 0 additions and 39 deletions
|
|
@ -190,16 +190,6 @@ deskflow::Screen *ClientApp::createScreen()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientApp::updateStatus() const
|
|
||||||
{
|
|
||||||
updateStatus("");
|
|
||||||
}
|
|
||||||
|
|
||||||
void ClientApp::updateStatus(const std::string_view &) const
|
|
||||||
{
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
deskflow::Screen *ClientApp::openClientScreen()
|
deskflow::Screen *ClientApp::openClientScreen()
|
||||||
{
|
{
|
||||||
deskflow::Screen *screen = createScreen();
|
deskflow::Screen *screen = createScreen();
|
||||||
|
|
@ -238,7 +228,6 @@ void ClientApp::scheduleClientRestart(double retryTime)
|
||||||
void ClientApp::handleClientConnected() const
|
void ClientApp::handleClientConnected() const
|
||||||
{
|
{
|
||||||
LOG((CLOG_NOTE "connected to server"));
|
LOG((CLOG_NOTE "connected to server"));
|
||||||
updateStatus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClientApp::handleClientFailed(const Event &e)
|
void ClientApp::handleClientFailed(const Event &e)
|
||||||
|
|
@ -246,7 +235,6 @@ void ClientApp::handleClientFailed(const Event &e)
|
||||||
if ((++m_lastServerAddressIndex) < m_client->getLastResolvedAddressesCount()) {
|
if ((++m_lastServerAddressIndex) < m_client->getLastResolvedAddressesCount()) {
|
||||||
std::unique_ptr<Client::FailInfo> info(static_cast<Client::FailInfo *>(e.getData()));
|
std::unique_ptr<Client::FailInfo> info(static_cast<Client::FailInfo *>(e.getData()));
|
||||||
|
|
||||||
updateStatus(std::string("Failed to connect to server: ") + info->m_what + " Trying next address...");
|
|
||||||
LOG((CLOG_WARN "failed to connect to server=%s, trying next address", info->m_what.c_str()));
|
LOG((CLOG_WARN "failed to connect to server=%s, trying next address", info->m_what.c_str()));
|
||||||
if (!m_suspended) {
|
if (!m_suspended) {
|
||||||
scheduleClientRestart(s_retryTime);
|
scheduleClientRestart(s_retryTime);
|
||||||
|
|
@ -261,7 +249,6 @@ void ClientApp::handleClientRefused(const Event &e)
|
||||||
{
|
{
|
||||||
std::unique_ptr<Client::FailInfo> info(static_cast<Client::FailInfo *>(e.getData()));
|
std::unique_ptr<Client::FailInfo> info(static_cast<Client::FailInfo *>(e.getData()));
|
||||||
|
|
||||||
updateStatus(std::string("Failed to connect to server: ") + info->m_what);
|
|
||||||
if (!args().m_restartable || !info->m_retry) {
|
if (!args().m_restartable || !info->m_retry) {
|
||||||
LOG((CLOG_ERR "failed to connect to server: %s", info->m_what.c_str()));
|
LOG((CLOG_ERR "failed to connect to server: %s", info->m_what.c_str()));
|
||||||
getEvents()->addEvent(Event(EventTypes::Quit));
|
getEvents()->addEvent(Event(EventTypes::Quit));
|
||||||
|
|
@ -281,7 +268,6 @@ void ClientApp::handleClientDisconnected()
|
||||||
} else if (!m_suspended) {
|
} else if (!m_suspended) {
|
||||||
scheduleClientRestart(s_retryTime);
|
scheduleClientRestart(s_retryTime);
|
||||||
}
|
}
|
||||||
updateStatus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Client *ClientApp::openClient(const std::string &name, const NetworkAddress &address, deskflow::Screen *screen)
|
Client *ClientApp::openClient(const std::string &name, const NetworkAddress &address, deskflow::Screen *screen)
|
||||||
|
|
@ -345,12 +331,10 @@ bool ClientApp::startClient()
|
||||||
|
|
||||||
m_client->connect(m_lastServerAddressIndex);
|
m_client->connect(m_lastServerAddressIndex);
|
||||||
|
|
||||||
updateStatus();
|
|
||||||
return true;
|
return true;
|
||||||
} catch (XScreenUnavailable &e) {
|
} catch (XScreenUnavailable &e) {
|
||||||
LOG((CLOG_WARN "secondary screen unavailable: %s", e.what()));
|
LOG((CLOG_WARN "secondary screen unavailable: %s", e.what()));
|
||||||
closeClientScreen(clientScreen);
|
closeClientScreen(clientScreen);
|
||||||
updateStatus(std::string("secondary screen unavailable: ") + e.what());
|
|
||||||
retryTime = e.getRetryTime();
|
retryTime = e.getRetryTime();
|
||||||
} catch (XScreenOpenFailure &e) {
|
} catch (XScreenOpenFailure &e) {
|
||||||
LOG((CLOG_CRIT "failed to start client: %s", e.what()));
|
LOG((CLOG_CRIT "failed to start client: %s", e.what()));
|
||||||
|
|
@ -411,7 +395,6 @@ int ClientApp::mainLoop()
|
||||||
// close down
|
// close down
|
||||||
LOG((CLOG_DEBUG1 "stopping client"));
|
LOG((CLOG_DEBUG1 "stopping client"));
|
||||||
stopClient();
|
stopClient();
|
||||||
updateStatus();
|
|
||||||
LOG((CLOG_NOTE "stopped client"));
|
LOG((CLOG_NOTE "stopped client"));
|
||||||
|
|
||||||
return s_exitSuccess;
|
return s_exitSuccess;
|
||||||
|
|
|
||||||
|
|
@ -62,9 +62,6 @@ public:
|
||||||
//
|
//
|
||||||
// Regular functions
|
// Regular functions
|
||||||
//
|
//
|
||||||
|
|
||||||
void updateStatus() const;
|
|
||||||
void updateStatus(const std::string_view &) const;
|
|
||||||
deskflow::Screen *openClientScreen();
|
deskflow::Screen *openClientScreen();
|
||||||
void closeClientScreen(deskflow::Screen *screen);
|
void closeClientScreen(deskflow::Screen *screen);
|
||||||
void handleClientRestart(const Event &, EventQueueTimer *vtimer);
|
void handleClientRestart(const Event &, EventQueueTimer *vtimer);
|
||||||
|
|
|
||||||
|
|
@ -203,7 +203,6 @@ void ServerApp::handleClientConnected(const Event &, ClientListener *listener)
|
||||||
ClientProxy *client = listener->getNextClient();
|
ClientProxy *client = listener->getNextClient();
|
||||||
if (client != nullptr) {
|
if (client != nullptr) {
|
||||||
m_server->adoptClient(client);
|
m_server->adoptClient(client);
|
||||||
updateStatus();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -245,16 +244,6 @@ void ServerApp::stopRetryTimer()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerApp::updateStatus() const
|
|
||||||
{
|
|
||||||
updateStatus("");
|
|
||||||
}
|
|
||||||
|
|
||||||
void ServerApp::updateStatus(const std::string_view &msg) const
|
|
||||||
{
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
void ServerApp::closeClientListener(ClientListener *listen)
|
void ServerApp::closeClientListener(ClientListener *listen)
|
||||||
{
|
{
|
||||||
if (listen != nullptr) {
|
if (listen != nullptr) {
|
||||||
|
|
@ -379,13 +368,11 @@ bool ServerApp::initServer()
|
||||||
m_serverScreen = serverScreen;
|
m_serverScreen = serverScreen;
|
||||||
m_primaryClient = primaryClient;
|
m_primaryClient = primaryClient;
|
||||||
m_serverState = Initialized;
|
m_serverState = Initialized;
|
||||||
updateStatus();
|
|
||||||
return true;
|
return true;
|
||||||
} catch (XScreenUnavailable &e) {
|
} catch (XScreenUnavailable &e) {
|
||||||
LOG((CLOG_WARN "primary screen unavailable: %s", e.what()));
|
LOG((CLOG_WARN "primary screen unavailable: %s", e.what()));
|
||||||
closePrimaryClient(primaryClient);
|
closePrimaryClient(primaryClient);
|
||||||
closeServerScreen(serverScreen);
|
closeServerScreen(serverScreen);
|
||||||
updateStatus(std::string("primary screen unavailable: ") + e.what());
|
|
||||||
retryTime = e.getRetryTime();
|
retryTime = e.getRetryTime();
|
||||||
} catch (XScreenOpenFailure &e) {
|
} catch (XScreenOpenFailure &e) {
|
||||||
LOG((CLOG_CRIT "failed to start server: %s", e.what()));
|
LOG((CLOG_CRIT "failed to start server: %s", e.what()));
|
||||||
|
|
@ -455,7 +442,6 @@ bool ServerApp::startServer()
|
||||||
listener->setServer(m_server);
|
listener->setServer(m_server);
|
||||||
m_server->setListener(listener);
|
m_server->setListener(listener);
|
||||||
m_listener = listener;
|
m_listener = listener;
|
||||||
updateStatus();
|
|
||||||
LOG((CLOG_NOTE "started server, waiting for clients"));
|
LOG((CLOG_NOTE "started server, waiting for clients"));
|
||||||
m_serverState = Started;
|
m_serverState = Started;
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -466,7 +452,6 @@ bool ServerApp::startServer()
|
||||||
LOG((CLOG_CRIT "cannot listen for clients: %s", e.what()));
|
LOG((CLOG_CRIT "cannot listen for clients: %s", e.what()));
|
||||||
}
|
}
|
||||||
closeClientListener(listener);
|
closeClientListener(listener);
|
||||||
updateStatus(std::string("cannot listen for clients: ") + e.what());
|
|
||||||
} catch (XBase &e) {
|
} catch (XBase &e) {
|
||||||
LOG((CLOG_CRIT "failed to start server: %s", e.what()));
|
LOG((CLOG_CRIT "failed to start server: %s", e.what()));
|
||||||
closeClientListener(listener);
|
closeClientListener(listener);
|
||||||
|
|
@ -562,7 +547,6 @@ Server *ServerApp::openServer(ServerConfig &config, PrimaryClient *primaryClient
|
||||||
{
|
{
|
||||||
auto *server = new Server(config, primaryClient, m_serverScreen, getEvents(), args());
|
auto *server = new Server(config, primaryClient, m_serverScreen, getEvents(), args());
|
||||||
try {
|
try {
|
||||||
getEvents()->addHandler(EventTypes::ServerDisconnected, server, [this](const auto &) { updateStatus(); });
|
|
||||||
getEvents()->addHandler(EventTypes::ServerScreenSwitched, server, [this](const auto &) { handleScreenSwitched(); });
|
getEvents()->addHandler(EventTypes::ServerScreenSwitched, server, [this](const auto &) { handleScreenSwitched(); });
|
||||||
|
|
||||||
} catch (std::bad_alloc &ba) {
|
} catch (std::bad_alloc &ba) {
|
||||||
|
|
@ -661,7 +645,6 @@ int ServerApp::mainLoop()
|
||||||
getEvents()->removeHandler(EventTypes::ServerAppForceReconnect, getEvents()->getSystemTarget());
|
getEvents()->removeHandler(EventTypes::ServerAppForceReconnect, getEvents()->getSystemTarget());
|
||||||
getEvents()->removeHandler(EventTypes::ServerAppReloadConfig, getEvents()->getSystemTarget());
|
getEvents()->removeHandler(EventTypes::ServerAppReloadConfig, getEvents()->getSystemTarget());
|
||||||
cleanupServer();
|
cleanupServer();
|
||||||
updateStatus();
|
|
||||||
LOG((CLOG_NOTE "stopped server"));
|
LOG((CLOG_NOTE "stopped server"));
|
||||||
|
|
||||||
return s_exitSuccess;
|
return s_exitSuccess;
|
||||||
|
|
|
||||||
|
|
@ -87,8 +87,6 @@ public:
|
||||||
void handleClientConnected(const Event &e, ClientListener *listener);
|
void handleClientConnected(const Event &e, ClientListener *listener);
|
||||||
void closeServer(Server *server);
|
void closeServer(Server *server);
|
||||||
void stopRetryTimer();
|
void stopRetryTimer();
|
||||||
void updateStatus() const;
|
|
||||||
void updateStatus(const std::string_view &msg) const;
|
|
||||||
void closeClientListener(ClientListener *listen);
|
void closeClientListener(ClientListener *listen);
|
||||||
void stopServer();
|
void stopServer();
|
||||||
void closePrimaryClient(PrimaryClient *primaryClient);
|
void closePrimaryClient(PrimaryClient *primaryClient);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue