Some improvements for Android compatibility

This commit is contained in:
Christian Basler 2017-07-10 06:08:20 +02:00
parent 1a33f744d6
commit 009346cd30
2 changed files with 11 additions and 10 deletions

View File

@ -50,6 +50,14 @@ subprojects {
from sourceSets.main.allSource from sourceSets.main.allSource
} }
compileKotlin {
kotlinOptions.jvmTarget = "1.6"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.6"
}
artifacts { artifacts {
archives javadocJar, sourcesJar archives javadocJar, sourcesJar
} }

View File

@ -134,7 +134,7 @@ class NioNetworkHandler : NetworkHandler, InternalContext.ContextHolder {
starter = thread("connection manager") { starter = thread("connection manager") {
while (selector.isOpen) { while (selector.isOpen) {
var missing = NETWORK_MAGIC_NUMBER var missing = NETWORK_MAGIC_NUMBER
for (connection in connections.keys) { for ((connection, _) in connections) {
if (connection.state == Connection.State.ACTIVE) { if (connection.state == Connection.State.ACTIVE) {
missing-- missing--
if (missing == 0) break if (missing == 0) break
@ -351,7 +351,7 @@ class NioNetworkHandler : NetworkHandler, InternalContext.ContextHolder {
} }
val distribution = HashMap<Connection, MutableList<InventoryVector>>() val distribution = HashMap<Connection, MutableList<InventoryVector>>()
for (connection in connections.keys) { for ((connection, _) in connections) {
if (connection.state == Connection.State.ACTIVE) { if (connection.state == Connection.State.ACTIVE) {
distribution.put(connection, mutableListOf<InventoryVector>()) distribution.put(connection, mutableListOf<InventoryVector>())
} }
@ -436,14 +436,7 @@ class NioNetworkHandler : NetworkHandler, InternalContext.ContextHolder {
) )
} }
private fun isConnectedTo(address: NetworkAddress): Boolean { private fun isConnectedTo(address: NetworkAddress): Boolean = connections.any { it.key.node == address }
for (c in connections.keys) {
if (c.node == address) {
return true
}
}
return false
}
override val isRunning: Boolean override val isRunning: Boolean
get() = selector?.isOpen ?: false && starter?.isAlive ?: false get() = selector?.isOpen ?: false && starter?.isAlive ?: false