sync
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
package cc.maxmc.msm.common.network
|
||||
|
||||
import cc.maxmc.msm.common.event.PacketReceiveEvent
|
||||
import io.netty.channel.ChannelHandlerContext
|
||||
import io.netty.channel.SimpleChannelInboundHandler
|
||||
|
||||
object ClusterPacketHandler : SimpleChannelInboundHandler<BungeePacket>() {
|
||||
override fun channelRead0(ctx: ChannelHandlerContext, msg: BungeePacket) {
|
||||
PacketReceiveEvent(ctx.channel(), msg).callEvent()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package cc.maxmc.msm.common.utils
|
||||
|
||||
import net.md_5.bungee.api.ProxyServer
|
||||
import net.md_5.bungee.api.chat.TextComponent
|
||||
|
||||
fun log(msg: String) {
|
||||
ProxyServer.getInstance().console.sendMessage(TextComponent(msg))
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package cc.maxmc.msm.common.utils
|
||||
|
||||
import cc.maxmc.msm.common.network.ClusterPacketHandler
|
||||
import cc.maxmc.msm.common.network.netty.ClusterMsgCodec
|
||||
import cc.maxmc.msm.common.network.netty.NetworkRegistry
|
||||
import io.netty.channel.Channel
|
||||
import io.netty.channel.ChannelInitializer
|
||||
import io.netty.channel.SimpleChannelInboundHandler
|
||||
import io.netty.channel.socket.SocketChannel
|
||||
import net.md_5.bungee.protocol.Varint21FrameDecoder
|
||||
import net.md_5.bungee.protocol.Varint21LengthFieldPrepender
|
||||
@@ -15,9 +15,9 @@ fun <C : Channel> channelInit(initializer: C.() -> Unit): ChannelInitializer<C>
|
||||
}
|
||||
}
|
||||
|
||||
fun <I> pipelineInit(packetHandler: SimpleChannelInboundHandler<I>) = channelInit<SocketChannel> {
|
||||
fun pipelineInit() = channelInit<SocketChannel> {
|
||||
pipeline().addLast("frame_decoder", Varint21FrameDecoder())
|
||||
pipeline().addLast("codec", ClusterMsgCodec(NetworkRegistry.PacketDirection.CHILD_BOUND))
|
||||
pipeline().addLast("frame_prepender", Varint21LengthFieldPrepender())
|
||||
pipeline().addLast("packet_handler", packetHandler)
|
||||
pipeline().addLast("packet_handler", ClusterPacketHandler)
|
||||
}
|
||||
Reference in New Issue
Block a user