mirror of
https://github.com/ViaVersion/VIAaaS.git
synced 2024-11-22 12:05:45 +01:00
code cleanup
This commit is contained in:
parent
428d47a9b9
commit
d3325612a8
@ -19,6 +19,6 @@ class BackEndInit(val connectionData: ConnectionData) : ChannelInitializer<Chann
|
||||
// compress
|
||||
.addLast("via-codec", ViaCodec(user))
|
||||
.addLast("mc", MinecraftCodec())
|
||||
.addLast("handler", MinecraftHandler(connectionData, connectionData.frontChannel, frontEnd = false))
|
||||
.addLast("handler", MinecraftHandler(connectionData, frontEnd = false))
|
||||
}
|
||||
}
|
@ -19,7 +19,7 @@ object FrontEndInit : ChannelInitializer<Channel>() {
|
||||
.addLast("mc", MinecraftCodec())
|
||||
.addLast(
|
||||
"handler", MinecraftHandler(
|
||||
ConnectionData(frontChannel = ch), other = null, frontEnd = true
|
||||
ConnectionData(frontChannel = ch), frontEnd = true
|
||||
)
|
||||
)
|
||||
}
|
||||
|
@ -11,10 +11,10 @@ import java.net.SocketAddress
|
||||
|
||||
class MinecraftHandler(
|
||||
val data: ConnectionData,
|
||||
var other: Channel?,
|
||||
val frontEnd: Boolean
|
||||
) : SimpleChannelInboundHandler<Packet>() {
|
||||
var remoteAddress: SocketAddress? = null
|
||||
val other: Channel? get() = if (frontEnd) data.backChannel else data.frontChannel
|
||||
|
||||
override fun channelRead0(ctx: ChannelHandlerContext, packet: Packet) {
|
||||
if (ctx.channel().isActive) {
|
||||
|
@ -89,9 +89,7 @@ class HandshakeState : MinecraftConnectionState {
|
||||
if (it.isSuccess) {
|
||||
mcLogger.info("Connected ${handler.remoteAddress} -> $socketAddr")
|
||||
|
||||
val backChan = future.channel() as SocketChannel
|
||||
handler.data.backChannel = backChan
|
||||
handler.other = backChan
|
||||
handler.data.backChannel = future.channel() as SocketChannel
|
||||
|
||||
forward(handler, packet, true)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user