MCPcopy Create free account
hub / github.com/Windscribe/Desktop-App / onConnectionStateChanged

Method onConnectionStateChanged

src/windscribe-cli/backendcommander.cpp:104–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102}
103
104void BackendCommander::onConnectionStateChanged(int state, IPC::Connection * /*connection*/)
105{
106 if (state == IPC::CONNECTION_CONNECTED) {
107 qCDebug(LOG_CLI) << "Connected to app";
108 ipcState_ = IPC_CONNECTED;
109 loggedInTimer_.start();
110 sendStateCommand();
111 }
112 else if (state == IPC::CONNECTION_DISCONNECTED) {
113 qCDebug(LOG_CLI) << "Disconnected from app";
114 emit finished(0, "");
115 }
116 else if (state == IPC::CONNECTION_ERROR) {
117 if (ipcState_ == IPC_CONNECTING) {
118 if (connectingTimer_.isValid() && connectingTimer_.elapsed() > MAX_WAIT_TIME_MS) {
119 connectingTimer_.invalidate();
120 emit finished(1, QObject::tr("Aborting: app did not start in time"));
121 }
122 else {
123 // Try connect again. Delay is necessary so that Engine process will actually start
124 // running on low resource systems.
125 QTimer::singleShot(100, this, [this]() { connection_->connect(); } );
126 }
127 }
128 else {
129 emit finished(1, QObject::tr("Aborting: IPC communication error"));
130 }
131 }
132}
133
134void BackendCommander::sendCommand(IPC::CliCommands::State *state)
135{

Callers

nothing calls this directly

Calls 3

startMethod · 0.45
isValidMethod · 0.45
connectMethod · 0.45

Tested by

no test coverage detected