Add CoroutineExceptionHandler to LoginChannelHandler

Signed-off-by: Graham <gpe@openrs2.org>
Graham 2 years ago
parent 0814443bc5
commit 4ef349d0ac
  1. 7
      game/src/main/kotlin/org/openrs2/game/net/login/LoginChannelHandler.kt

@ -16,6 +16,7 @@ import io.netty.handler.codec.http.HttpRequestDecoder
import io.netty.handler.codec.http.HttpResponseEncoder
import io.netty.handler.codec.string.StringDecoder
import io.netty.handler.timeout.IdleStateEvent
import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.asCoroutineDispatcher
import kotlinx.coroutines.cancel
@ -66,7 +67,11 @@ public class LoginChannelHandler @Inject constructor(
private var serverKey = 0L
override fun handlerAdded(ctx: ChannelHandlerContext) {
scope = CoroutineScope(ctx.executor().asCoroutineDispatcher())
val exceptionHandler = CoroutineExceptionHandler { _, ex ->
ctx.fireExceptionCaught(ex)
}
scope = CoroutineScope(ctx.executor().asCoroutineDispatcher() + exceptionHandler)
}
override fun handlerRemoved(ctx: ChannelHandlerContext) {

Loading…
Cancel
Save