fix Packet

This commit is contained in:
tony_all
2023-03-16 00:06:48 +08:00
parent 8c41f190c4
commit 2abf1bb7df
13 changed files with 52 additions and 42 deletions
@@ -1,5 +1,6 @@
package cc.maxmc.msm.parent.netty
import cc.maxmc.msm.common.network.netty.NetworkRegistry
import cc.maxmc.msm.common.utils.log
import cc.maxmc.msm.common.utils.pipelineInit
import cc.maxmc.msm.parent.settings.Settings
@@ -9,14 +10,14 @@ import io.netty.channel.nio.NioEventLoopGroup
import io.netty.channel.socket.nio.NioServerSocketChannel
object NetManager {
val parentGroup = NioEventLoopGroup()
val childGroup = NioEventLoopGroup()
private val parentGroup = NioEventLoopGroup()
private val childGroup = NioEventLoopGroup()
fun startServer() {
ServerBootstrap()
.channel(NioServerSocketChannel::class.java)
.group(parentGroup, childGroup)
.childHandler(pipelineInit())
.childHandler(pipelineInit(NetworkRegistry.PacketDirection.PARENT_BOUND))
.bind(Settings.serverPort)
.addListener(ChannelFutureListener {
log("§a| §7集群主服务端启动成功. ${it.channel().localAddress()}")
@@ -1,13 +0,0 @@
package cc.maxmc.msm.parent.netty
import cc.maxmc.msm.common.event.PacketReceiveEvent
import cc.maxmc.msm.common.network.BungeePacket
import io.netty.channel.ChannelHandlerContext
import io.netty.channel.SimpleChannelInboundHandler
object ParentPacketHandler : SimpleChannelInboundHandler<BungeePacket>() {
override fun channelRead0(ctx: ChannelHandlerContext, msg: BungeePacket) {
PacketReceiveEvent(ctx.channel(), msg).callEvent()
}
}