From a22b32f6073c173d64c38154af21fb07ec09c3a9 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Sun, 25 Sep 2016 20:16:42 +0900 Subject: [PATCH] Retry internet connections if all nodes disconnected --- .../nutomic/ensichat/core/internet/InternetInterface.scala | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/src/main/scala/com/nutomic/ensichat/core/internet/InternetInterface.scala b/core/src/main/scala/com/nutomic/ensichat/core/internet/InternetInterface.scala index 853e52e..a9f9b4c 100644 --- a/core/src/main/scala/com/nutomic/ensichat/core/internet/InternetInterface.scala +++ b/core/src/main/scala/com/nutomic/ensichat/core/internet/InternetInterface.scala @@ -63,7 +63,7 @@ private[core] class InternetInterface(connectionHandler: ConnectionHandler, cryp .map(_.trim()) .filterNot(_.isEmpty) - Random.shuffle(addresses.toList) + addresses.toList .foreach(openConnection) } @@ -104,6 +104,11 @@ private[core] class InternetInterface(connectionHandler: ConnectionHandler, cryp addressDeviceMap -= ad val connectionDuration = new Duration(connectionThread.connectionOpened, DateTime.now) connectionHandler.onConnectionClosed(ad, connectionDuration) + + // If we aren't connected to any nodes, try to connect again. + if (connections.isEmpty) { + openAllConnections() + } } }