Skip to content

Commit

Permalink
Merge pull request #525 from lenguyenthanh/shutdown-channel-correctly
Browse files Browse the repository at this point in the history
Shutdown channel correctly
  • Loading branch information
lenguyenthanh authored Feb 19, 2024
2 parents f2d531a + 7f47bc3 commit 04407c6
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/main/scala/netty/FrameHandler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ package lila.ws
package netty

import com.typesafe.scalalogging.Logger
import io.netty.channel.Channel
import io.netty.channel.ChannelHandlerContext
import io.netty.channel.SimpleChannelInboundHandler
import io.netty.channel.*
import io.netty.handler.codec.http.websocketx.*

import io.netty.util.concurrent.GenericFutureListener
import ipc.ClientOut

final private class FrameHandler(using Executor) extends SimpleChannelInboundHandler[WebSocketFrame]:
Expand Down Expand Up @@ -59,7 +57,8 @@ final private class FrameHandler(using Executor) extends SimpleChannelInboundHan
shutdown(channel, 1011, s"no actor on $channel")

private def shutdown(channel: Channel, code: Int, reason: String): Unit =
channel.writeAndFlush(CloseWebSocketFrame(code, reason)).addListener(_ => channel.close())
val close: GenericFutureListener[ChannelFuture] = _ => channel.close()
channel.writeAndFlush(CloseWebSocketFrame(code, reason)).addListener(close)

private object FrameHandler:

Expand Down

0 comments on commit 04407c6

Please sign in to comment.