Skip to content

Commit

Permalink
Remove the duplicated code in NettyHelpers.
Browse files Browse the repository at this point in the history
  • Loading branch information
He-Pin committed Sep 12, 2023
1 parent a92c2d1 commit 6a6639f
Showing 1 changed file with 9 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,16 @@ private[netty] trait NettyHelpers {
/**
* INTERNAL API
*/
private[netty] trait NettyServerHelpers extends SimpleChannelInboundHandler[ByteBuf] with NettyHelpers {

private[netty] abstract class NettyChannelHandlerAdapter extends SimpleChannelInboundHandler[ByteBuf]
with NettyHelpers {
final override def channelRead0(ctx: ChannelHandlerContext, msg: ByteBuf): Unit = {
onMessage(ctx, msg)
}

@nowarn("msg=deprecated")
final override def exceptionCaught(ctx: ChannelHandlerContext, cause: Throwable): Unit =
final override def exceptionCaught(ctx: ChannelHandlerContext, cause: Throwable): Unit = {
transformException(ctx, cause)
}

final override def channelActive(ctx: ChannelHandlerContext): Unit = {
onOpen(ctx)
Expand All @@ -75,23 +76,9 @@ private[netty] trait NettyServerHelpers extends SimpleChannelInboundHandler[Byte
/**
* INTERNAL API
*/
private[netty] trait NettyClientHelpers extends SimpleChannelInboundHandler[ByteBuf] with NettyHelpers {

final override def channelRead0(ctx: ChannelHandlerContext, msg: ByteBuf): Unit = {
onMessage(ctx, msg)
}

@nowarn("msg=deprecated")
final override def exceptionCaught(ctx: ChannelHandlerContext, cause: Throwable): Unit = {
transformException(ctx, cause)
}
private[netty] trait NettyServerHelpers extends NettyChannelHandlerAdapter

final override def channelActive(ctx: ChannelHandlerContext): Unit = {
onOpen(ctx)
onConnect(ctx)
}

final override def channelInactive(ctx: ChannelHandlerContext): Unit = {
onDisconnect(ctx)
}
}
/**
* INTERNAL API
*/
private[netty] trait NettyClientHelpers extends NettyChannelHandlerAdapter

0 comments on commit 6a6639f

Please sign in to comment.