inline quint16 localPort() const { return socket.localPort(); }
inline quint16 peerPort() const { return socket.peerPort(); }
+ /**
+ * Gets whether or not a disconnect was expected.
+ *
+ * Distinguishes desired quits from unexpected disconnections such as socket errors or timeouts.
+ *
+ * @return True if disconnect was requested, otherwise false.
+ */
+ inline bool disconnectExpected() const { return _disconnectExpected; }
+
QList<QList<QByteArray>> splitMessage(const QString &cmd, const QString &message, std::function<QList<QByteArray>(QString &)> cmdGenerator);
public slots:
void disconnectFromIrc(bool requested = true, const QString &reason = QString(),
bool withReconnect = false, bool forceImmediate = false);
+ /**
+ * Forcibly close the IRC server socket, waiting for it to close.
+ *
+ * Call CoreNetwork::disconnectFromIrc() first, allow the event loop to run, then if you need to
+ * be sure the network's disconencted (e.g. clean-up), call this.
+ *
+ * @param msecs Maximum time to wait for socket to close, in milliseconds.
+ * @return True if socket closes successfully; false if error occurs or timeout reached
+ */
+ bool forceDisconnect(int msecs = 1000);
+
void userInput(BufferInfo bufferInfo, QString msg);
/**
bool _quitRequested;
QString _quitReason;
+ bool _disconnectExpected; /// If true, connection is quitting, expect a socket close
+ // This avoids logging a spurious RemoteHostClosedError whenever disconnect is called without
+ // specifying a permanent (saved to core session) disconnect.
+
bool _previousConnectionAttemptFailed;
int _lastUsedServerIndex;