Skip to content

Commit

Permalink
remove unnecessary methods
Browse files Browse the repository at this point in the history
  • Loading branch information
schlawg committed Sep 23, 2024
1 parent 7befcad commit 509a207
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/main/scala/netty/ActorChannelConnector.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,15 @@ final private class ActorChannelConnector(clients: ActorRef[Clients.Control], lo
clients ! Clients.Control.Stop(client)
}

private inline def emitDisconnect(inline channel: Channel, inline reason: String): Unit =
channel
.writeAndFlush(CloseWebSocketFrame(WebSocketCloseStatus(4010, reason)))
.addListener(ChannelFutureListener.CLOSE)

private inline def emitPingFrame(inline channel: Channel): Unit =
channel.write { PingWebSocketFrame(Unpooled.copyLong(System.currentTimeMillis())) }

private def emitToChannel(channel: Channel, withFlush: Boolean): ClientEmit =
msg =>
msg.match
case ipc.ClientIn.Disconnect(reason) => emitDisconnect(channel, reason)
case ipc.ClientIn.RoundPingFrameNoFlush => emitPingFrame(channel)
case ipc.ClientIn.Disconnect(reason) =>
channel
.writeAndFlush(CloseWebSocketFrame(WebSocketCloseStatus(4010, reason)))
.addListener(ChannelFutureListener.CLOSE)
case ipc.ClientIn.RoundPingFrameNoFlush =>
channel.write { PingWebSocketFrame(Unpooled.copyLong(System.currentTimeMillis())) }
case in =>
if withFlush then channel.writeAndFlush(TextWebSocketFrame(in.write))
else loop.writeShaped(channel, TextWebSocketFrame(in.write))

0 comments on commit 509a207

Please sign in to comment.