- // TODO implement cycling / random servers
- QString host = serverList[0].toMap()["Host"].toString();
- quint16 port = serverList[0].toMap()["Port"].toUInt();
+ // use a random server?
+ if(network()->useRandomServer()) {
+ _lastUsedServerlistIndex = qrand() % serverList.size();
+ } else if(_previousConnectionAttemptFailed) {
+ // cycle to next server if previous connection attempt failed
+ displayMsg(Message::Server, BufferInfo::StatusBuffer, "", tr("Connection failed. Cycling to next Server"));
+ if(++_lastUsedServerlistIndex == serverList.size()) {
+ _lastUsedServerlistIndex = 0;
+ }
+ }
+ _previousConnectionAttemptFailed = false;
+
+ QString host = serverList[_lastUsedServerlistIndex].toMap()["Host"].toString();
+ quint16 port = serverList[_lastUsedServerlistIndex].toMap()["Port"].toUInt();