Search in sources :

Example 6 with ProtocolPipelineImpl

use of com.viaversion.viaversion.protocol.ProtocolPipelineImpl in project ViaVersion by ViaVersion.

the class BungeeChannelInitializer method initChannel.

@Override
protected void initChannel(Channel socketChannel) throws Exception {
    if (!socketChannel.isActive()) {
        return;
    }
    UserConnection info = new UserConnectionImpl(socketChannel);
    // init protocol
    new ProtocolPipelineImpl(info);
    // Add originals
    this.method.invoke(this.original, socketChannel);
    // Don't inject if inactive
    if (!socketChannel.isActive())
        return;
    // Don't inject if no packet-encoder
    if (socketChannel.pipeline().get("packet-encoder") == null)
        return;
    // Don't inject if no packet-decoder
    if (socketChannel.pipeline().get("packet-decoder") == null)
        return;
    // Add our transformers
    BungeeEncodeHandler encoder = new BungeeEncodeHandler(info);
    BungeeDecodeHandler decoder = new BungeeDecodeHandler(info);
    socketChannel.pipeline().addBefore("packet-encoder", "via-encoder", encoder);
    socketChannel.pipeline().addBefore("packet-decoder", "via-decoder", decoder);
}
Also used : UserConnectionImpl(com.viaversion.viaversion.connection.UserConnectionImpl) ProtocolPipelineImpl(com.viaversion.viaversion.protocol.ProtocolPipelineImpl) UserConnection(com.viaversion.viaversion.api.connection.UserConnection)

Example 7 with ProtocolPipelineImpl

use of com.viaversion.viaversion.protocol.ProtocolPipelineImpl in project LiquidBouncePlus by WYSI-Foundation.

the class MixinNetworkManagerChInit method onInitChannel.

@Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false)
private void onInitChannel(Channel channel, CallbackInfo ci) {
    if (channel instanceof SocketChannel && ViaForge.getInstance().getVersion() != ViaForge.SHARED_VERSION) {
        UserConnection user = new UserConnectionImpl(channel, true);
        new ProtocolPipelineImpl(user);
        channel.pipeline().addBefore("encoder", CommonTransformer.HANDLER_ENCODER_NAME, new EncodeHandler(user)).addBefore("decoder", CommonTransformer.HANDLER_DECODER_NAME, new DecodeHandler(user));
    }
}
Also used : EncodeHandler(de.enzaxd.viaforge.handler.EncodeHandler) SocketChannel(io.netty.channel.socket.SocketChannel) UserConnectionImpl(com.viaversion.viaversion.connection.UserConnectionImpl) ProtocolPipelineImpl(com.viaversion.viaversion.protocol.ProtocolPipelineImpl) UserConnection(com.viaversion.viaversion.api.connection.UserConnection) DecodeHandler(de.enzaxd.viaforge.handler.DecodeHandler) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 8 with ProtocolPipelineImpl

use of com.viaversion.viaversion.protocol.ProtocolPipelineImpl in project ViaFabric by ViaVersion.

the class MixinServerNetworkIoChInit method onInitChannel.

@Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false)
private void onInitChannel(Channel channel, CallbackInfo ci) {
    if (channel instanceof SocketChannel) {
        UserConnection user = new UserConnectionImpl(channel);
        new ProtocolPipelineImpl(user);
        channel.pipeline().addBefore("encoder", CommonTransformer.HANDLER_ENCODER_NAME, new FabricEncodeHandler(user));
        channel.pipeline().addBefore("decoder", CommonTransformer.HANDLER_DECODER_NAME, new FabricDecodeHandler(user));
    }
}
Also used : SocketChannel(io.netty.channel.socket.SocketChannel) UserConnectionImpl(com.viaversion.viaversion.connection.UserConnectionImpl) ProtocolPipelineImpl(com.viaversion.viaversion.protocol.ProtocolPipelineImpl) FabricDecodeHandler(com.viaversion.fabric.common.handler.FabricDecodeHandler) UserConnection(com.viaversion.viaversion.api.connection.UserConnection) FabricEncodeHandler(com.viaversion.fabric.common.handler.FabricEncodeHandler) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 9 with ProtocolPipelineImpl

use of com.viaversion.viaversion.protocol.ProtocolPipelineImpl in project ViaFabric by ViaVersion.

the class MixinClientConnectionChInit method onInitChannel.

@Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false)
private void onInitChannel(Channel channel, CallbackInfo ci) {
    if (channel instanceof SocketChannel) {
        UserConnection user = new UserConnectionImpl(channel, true);
        new ProtocolPipelineImpl(user).add(HostnameParserProtocol.INSTANCE);
        channel.pipeline().addBefore("encoder", CommonTransformer.HANDLER_ENCODER_NAME, new FabricEncodeHandler(user)).addBefore("decoder", CommonTransformer.HANDLER_DECODER_NAME, new FabricDecodeHandler(user));
    }
}
Also used : SocketChannel(io.netty.channel.socket.SocketChannel) UserConnectionImpl(com.viaversion.viaversion.connection.UserConnectionImpl) ProtocolPipelineImpl(com.viaversion.viaversion.protocol.ProtocolPipelineImpl) FabricDecodeHandler(com.viaversion.fabric.common.handler.FabricDecodeHandler) UserConnection(com.viaversion.viaversion.api.connection.UserConnection) FabricEncodeHandler(com.viaversion.fabric.common.handler.FabricEncodeHandler) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 10 with ProtocolPipelineImpl

use of com.viaversion.viaversion.protocol.ProtocolPipelineImpl in project ViaFabric by ViaVersion.

the class MixinServerNetworkIoChInit method onInitChannel.

@Inject(method = "initChannel", at = @At(value = "TAIL"), remap = false)
private void onInitChannel(Channel channel, CallbackInfo ci) {
    if (channel instanceof SocketChannel) {
        UserConnection user = new UserConnectionImpl(channel);
        new ProtocolPipelineImpl(user);
        channel.pipeline().addBefore("encoder", CommonTransformer.HANDLER_ENCODER_NAME, new FabricEncodeHandler(user));
        channel.pipeline().addBefore("decoder", CommonTransformer.HANDLER_DECODER_NAME, new FabricDecodeHandler(user));
    }
}
Also used : SocketChannel(io.netty.channel.socket.SocketChannel) UserConnectionImpl(com.viaversion.viaversion.connection.UserConnectionImpl) ProtocolPipelineImpl(com.viaversion.viaversion.protocol.ProtocolPipelineImpl) FabricDecodeHandler(com.viaversion.fabric.common.handler.FabricDecodeHandler) UserConnection(com.viaversion.viaversion.api.connection.UserConnection) FabricEncodeHandler(com.viaversion.fabric.common.handler.FabricEncodeHandler) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

UserConnection (com.viaversion.viaversion.api.connection.UserConnection)20 UserConnectionImpl (com.viaversion.viaversion.connection.UserConnectionImpl)20 ProtocolPipelineImpl (com.viaversion.viaversion.protocol.ProtocolPipelineImpl)20 SocketChannel (io.netty.channel.socket.SocketChannel)16 Inject (org.spongepowered.asm.mixin.injection.Inject)15 FabricDecodeHandler (com.viaversion.fabric.common.handler.FabricDecodeHandler)14 FabricEncodeHandler (com.viaversion.fabric.common.handler.FabricEncodeHandler)14 ByteToMessageDecoder (io.netty.handler.codec.ByteToMessageDecoder)2 MessageToByteEncoder (io.netty.handler.codec.MessageToByteEncoder)2 LegacyPingVersionHandler (com.github.dirtpowered.dirtmv.network.server.codec.LegacyPingVersionHandler)1 PacketDecoder (com.github.dirtpowered.dirtmv.network.server.codec.PacketDecoder)1 PacketEncoder (com.github.dirtpowered.dirtmv.network.server.codec.PacketEncoder)1 ViaDecodeHandler (com.github.dirtpowered.dirtmv.viaversion.handler.ViaDecodeHandler)1 ViaEncodeHandler (com.github.dirtpowered.dirtmv.viaversion.handler.ViaEncodeHandler)1 HandlerConstructor (com.viaversion.viaversion.classgenerator.generated.HandlerConstructor)1 DecodeHandler (de.enzaxd.viaforge.handler.DecodeHandler)1 EncodeHandler (de.enzaxd.viaforge.handler.EncodeHandler)1 ByteBuf (io.netty.buffer.ByteBuf)1