diff --git a/android/src/main/scala/com/nutomic/ensichat/service/ChatService.scala b/android/src/main/scala/com/nutomic/ensichat/service/ChatService.scala index 6225806..4e8cec4 100644 --- a/android/src/main/scala/com/nutomic/ensichat/service/ChatService.scala +++ b/android/src/main/scala/com/nutomic/ensichat/service/ChatService.scala @@ -37,7 +37,7 @@ class ChatService extends Service { lazy val database = new Database(getDatabasePath("database"), settingsWrapper, callbackHandler) private lazy val connectionHandler = - new ConnectionHandler(settingsWrapper, database, callbackHandler, ChatService.newCrypto(this), 1) + new ConnectionHandler(settingsWrapper, database, callbackHandler, ChatService.newCrypto(this)) private val networkReceiver = new NetworkChangedReceiver() diff --git a/core/src/main/scala/com/nutomic/ensichat/core/ConnectionHandler.scala b/core/src/main/scala/com/nutomic/ensichat/core/ConnectionHandler.scala index 064bec0..3719b99 100644 --- a/core/src/main/scala/com/nutomic/ensichat/core/ConnectionHandler.scala +++ b/core/src/main/scala/com/nutomic/ensichat/core/ConnectionHandler.scala @@ -17,13 +17,9 @@ import scala.concurrent.Future /** * High-level handling of all message transfers and callbacks. - * - * @param maxInternetConnections Maximum number of concurrent connections that should be opened by - * [[InternetInterface]]. */ final class ConnectionHandler(settings: SettingsInterface, database: Database, callbacks: CallbackInterface, crypto: Crypto, - maxInternetConnections: Int, port: Int = InternetInterface.DefaultPort) { private val logger = Logger(this.getClass) @@ -68,7 +64,7 @@ final class ConnectionHandler(settings: SettingsInterface, database: Database, logger.info("Local user is " + settings.get(SettingsInterface.KeyUserName, "none") + " with status '" + settings.get(SettingsInterface.KeyUserStatus, "") + "'") transmissionInterfaces += - new InternetInterface(this, crypto, settings, maxInternetConnections, port) + new InternetInterface(this, crypto, settings, port) transmissionInterfaces.foreach(_.create()) database.getUnconfirmedMessages.foreach { m => val encrypted = crypto.encryptAndSign(m) 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 208774b..853e52e 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 @@ -23,11 +23,9 @@ private[core] object InternetInterface { /** * Handles all Internet connectivity. - * - * @param maxConnections Maximum number of concurrent connections that should be opened. */ private[core] class InternetInterface(connectionHandler: ConnectionHandler, crypto: Crypto, - settings: SettingsInterface, maxConnections: Int, port: Int) + settings: SettingsInterface, port: Int) extends TransmissionInterface { private val logger = Logger(this.getClass) @@ -48,7 +46,7 @@ private[core] class InternetInterface(connectionHandler: ConnectionHandler, cryp settings.put(SettingsInterface.KeyAddresses, servers) serverThread.start() - openAllConnections(maxConnections) + openAllConnections() } /** @@ -59,14 +57,13 @@ private[core] class InternetInterface(connectionHandler: ConnectionHandler, cryp connections.foreach(_.close()) } - private def openAllConnections(maxConnections: Int): Unit = { + private def openAllConnections(): Unit = { val addresses = settings.get(SettingsInterface.KeyAddresses, SettingsInterface.DefaultAddresses) .split(",") .map(_.trim()) .filterNot(_.isEmpty) Random.shuffle(addresses.toList) - .take(maxConnections) .foreach(openConnection) } @@ -148,7 +145,7 @@ private[core] class InternetInterface(connectionHandler: ConnectionHandler, cryp FutureHelper { logger.info("Network has changed. Closing all connections and connecting to bootstrap nodes again") connections.foreach(_.close()) - openAllConnections(maxConnections) + openAllConnections() } } diff --git a/integration/src/main/scala/com.nutomic.ensichat.integration/LocalNode.scala b/integration/src/main/scala/com.nutomic.ensichat.integration/LocalNode.scala index e223d92..57c3040 100644 --- a/integration/src/main/scala/com.nutomic.ensichat.integration/LocalNode.scala +++ b/integration/src/main/scala/com.nutomic.ensichat.integration/LocalNode.scala @@ -54,7 +54,7 @@ class LocalNode(val index: Int, configFolder: File) extends CallbackInterface { val crypto = new Crypto(settings, keyFolder) val database = new Database(databaseFile, settings, this) - val connectionHandler = new ConnectionHandler(settings, database, this, crypto, 0, port) + val connectionHandler = new ConnectionHandler(settings, database, this, crypto, port) val eventQueue = new FifoStream[(EventType.EventType, Option[Message])]() configFolder.mkdirs() diff --git a/server/src/main/scala/com/nutomic/ensichat/server/Main.scala b/server/src/main/scala/com/nutomic/ensichat/server/Main.scala index d98535c..044fe2a 100644 --- a/server/src/main/scala/com/nutomic/ensichat/server/Main.scala +++ b/server/src/main/scala/com/nutomic/ensichat/server/Main.scala @@ -24,7 +24,7 @@ object Main extends App with CallbackInterface { private lazy val settings = new Settings(ConfigFile) private lazy val crypto = new Crypto(settings, KeyFolder) private lazy val database = new Database(DatabaseFile, settings, this) - private lazy val connectionHandler = new ConnectionHandler(settings, database, this, crypto, 7) + private lazy val connectionHandler = new ConnectionHandler(settings, database, this, crypto) init()