Browse Source

Retry internet connections if all nodes disconnected

drone-io
Felix Ableitner 6 years ago
parent
commit
a22b32f607
  1. 7
      core/src/main/scala/com/nutomic/ensichat/core/internet/InternetInterface.scala

7
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()
}
}
}