Skip to content

Commit

Permalink
Close the socket on broker disconnect packet
Browse files Browse the repository at this point in the history
Bump version to 0.0.9
  • Loading branch information
davidepianca98 committed Mar 3, 2020
1 parent 0a6e65f commit 0f9a41b
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 7 deletions.
8 changes: 8 additions & 0 deletions .idea/artifacts/KMQTT_jvm_0_0_8.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/artifacts/KMQTT_jvm_0_0_9.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ repositories {
maven { url "https://jitpack.io" }
}
dependencies {
implementation 'com.github.davidepianca98:KMQTT:0.0.8'
implementation 'com.github.davidepianca98:KMQTT:0.0.9'
}
```

Expand All @@ -55,7 +55,7 @@ kotlin {
sourceSets {
commonMain {
dependencies {
implementation 'com.github.davidepianca98:KMQTT:0.0.8'
implementation 'com.github.davidepianca98:KMQTT:0.0.9'
}
}
}
Expand Down
15 changes: 14 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

group = "com.github.davidepianca98"
version = "0.0.8"
version = "0.0.9"

repositories {
mavenCentral()
Expand Down Expand Up @@ -116,3 +116,16 @@ tasks {
dependsOn("shadowJar")
}
}

publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/davidepianca98/KMQTT")
credentials {
username = project.findProperty("gpr.user") as String? ?: System.getenv("GITHUB_USERNAME")
password = project.findProperty("gpr.key") as String? ?: System.getenv("GITHUB_PACKAGES")
}
}
}
}
1 change: 1 addition & 0 deletions src/commonMain/kotlin/mqtt/broker/ClientConnection.kt
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class ClientConnection(
}

private fun close() {
client.close()
broker.sessions[clientId]?.disconnected()
}

Expand Down
2 changes: 2 additions & 0 deletions src/commonMain/kotlin/socket/Socket.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ expect open class Socket : SocketInterface {
override fun sendRemaining()

override fun read(): UByteArray?

override fun close()
}

open class IOException(message: String? = null) : Exception(message)
Expand Down
2 changes: 2 additions & 0 deletions src/commonMain/kotlin/socket/SocketInterface.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ interface SocketInterface {
fun sendRemaining()

fun read(): UByteArray?

fun close()
}
2 changes: 1 addition & 1 deletion src/jvmMain/kotlin/socket/Socket.kt
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ actual open class Socket(private val sendBuffer: ByteBuffer, private val receive
else null
}

fun close() {
actual override fun close() {
val channel = key?.channel() as SocketChannel
key?.cancel()
channel.close()
Expand Down
2 changes: 1 addition & 1 deletion src/linuxArm32HfpMain/kotlin/socket/Socket.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ actual open class Socket(
}
}

open fun close() {
actual override fun close() {
shutdown(socket, SHUT_WR)
close(socket)
}
Expand Down
2 changes: 1 addition & 1 deletion src/linuxX64Main/kotlin/socket/Socket.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ actual open class Socket(
}
}

open fun close() {
actual override fun close() {
shutdown(socket, SHUT_WR)
close(socket)
}
Expand Down
2 changes: 1 addition & 1 deletion src/mingwMain/kotlin/socket/Socket.kt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ actual open class Socket(
}
}

open fun close() {
actual override fun close() {
shutdown(socket, SD_SEND)
closesocket(socket)
}
Expand Down

0 comments on commit 0f9a41b

Please sign in to comment.