Lower the priority if a transport fails to also try others eventually
parent
45cdbf1911
commit
7b81aad01a
|
|
@ -271,6 +271,7 @@ void NymeaConnection::onError(QAbstractSocket::SocketError error)
|
||||||
if (!m_currentTransport) {
|
if (!m_currentTransport) {
|
||||||
// We're trying to connect and one of the transports failed...
|
// We're trying to connect and one of the transports failed...
|
||||||
if (m_transportCandidates.contains(transport)) {
|
if (m_transportCandidates.contains(transport)) {
|
||||||
|
m_transportCandidates.value(transport)->decreasePriority();
|
||||||
m_transportCandidates.remove(transport);
|
m_transportCandidates.remove(transport);
|
||||||
transport->deleteLater();
|
transport->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -326,7 +326,7 @@ void Connection::setManual(bool manual)
|
||||||
|
|
||||||
int Connection::priority() const
|
int Connection::priority() const
|
||||||
{
|
{
|
||||||
int prio = 0;
|
int prio = m_manualPriorityAdjust;
|
||||||
if (m_online) {
|
if (m_online) {
|
||||||
prio += 1000;
|
prio += 1000;
|
||||||
prio -= qMin(500, (int)m_lastSeen.secsTo(QDateTime::currentDateTime()));
|
prio -= qMin(500, (int)m_lastSeen.secsTo(QDateTime::currentDateTime()));
|
||||||
|
|
@ -359,3 +359,13 @@ int Connection::priority() const
|
||||||
}
|
}
|
||||||
return prio;
|
return prio;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Connection::increasePriority()
|
||||||
|
{
|
||||||
|
m_manualPriorityAdjust++;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Connection::decreasePriority()
|
||||||
|
{
|
||||||
|
m_manualPriorityAdjust--;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,8 @@ public:
|
||||||
bool manual() const;
|
bool manual() const;
|
||||||
void setManual(bool manual);
|
void setManual(bool manual);
|
||||||
int priority() const;
|
int priority() const;
|
||||||
|
void increasePriority();
|
||||||
|
void decreasePriority();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void onlineChanged();
|
void onlineChanged();
|
||||||
|
|
@ -91,6 +93,7 @@ private:
|
||||||
bool m_online = false;
|
bool m_online = false;
|
||||||
bool m_manual = false;
|
bool m_manual = false;
|
||||||
QDateTime m_lastSeen;
|
QDateTime m_lastSeen;
|
||||||
|
int m_manualPriorityAdjust = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Connections: public QAbstractListModel
|
class Connections: public QAbstractListModel
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue