sync
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
package cc.maxmc.msm.common.event
|
||||
|
||||
import cc.maxmc.msm.common.network.BungeePacket
|
||||
import io.netty.channel.Channel
|
||||
import net.md_5.bungee.api.plugin.Event
|
||||
|
||||
data class PacketReceiveEvent(val channel: Channel, val packet: BungeePacket) : Event()
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package cc.maxmc.msm.common.network
|
||||
package cc.maxmc.msm.common.network.netty
|
||||
|
||||
import cc.maxmc.msm.common.network.netty.NetworkRegistry
|
||||
import cc.maxmc.msm.common.network.BungeePacket
|
||||
import io.netty.buffer.ByteBuf
|
||||
import io.netty.channel.ChannelHandlerContext
|
||||
import io.netty.handler.codec.ByteToMessageCodec
|
||||
@@ -0,0 +1,23 @@
|
||||
package cc.maxmc.msm.common.utils
|
||||
|
||||
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
|
||||
|
||||
fun <C : Channel> channelInit(initializer: C.() -> Unit): ChannelInitializer<C> {
|
||||
return object : ChannelInitializer<C>() {
|
||||
override fun initChannel(ch: C) = initializer(ch)
|
||||
}
|
||||
}
|
||||
|
||||
fun <I> pipelineInit(packetHandler: SimpleChannelInboundHandler<I>) = 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)
|
||||
}
|
||||
Reference in New Issue
Block a user