Skip to content

Commit

Permalink
fix: memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsMateo committed Jun 30, 2023
1 parent 5af1930 commit 0f7873e
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/main/kotlin/org/starlane/graphqlwskt/client/ClientHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ internal class ClientHandler(
return
}

// println("<- ${MessageParser.toJson(msg)}")

when(msg) {
is ConnectionAck -> {
acknowledged = true
Expand Down Expand Up @@ -93,10 +91,12 @@ internal class ClientHandler(

override fun onClose(code: Int, reason: String?, remote: Boolean) {
scope.cancel()
subscriptions.clear()
}

override fun onError(ex: Exception?) {
scope.cancel()
subscriptions.clear()
}

fun <T : Any> subscribe(request: OperationRequest, type: KClass<T>): Flow<T> {
Expand All @@ -109,21 +109,16 @@ internal class ClientHandler(
},
onComplete = {
close()
subscriptions.remove(id)
},
onError = {
close(it)
subscriptions.remove(id)
}
)

send(Subscribe(id, request))
awaitClose()
}
}

// override fun send(text: String) {
// println("-> $text")
//
// super.send(text)
// }

}

0 comments on commit 0f7873e

Please sign in to comment.