Search in sources :

Example 16 with UserConnectionImpl

use of com.viaversion.viaversion.connection.UserConnectionImpl 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 17 with UserConnectionImpl

use of com.viaversion.viaversion.connection.UserConnectionImpl 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 18 with UserConnectionImpl

use of com.viaversion.viaversion.connection.UserConnectionImpl in project ViaVersion by ViaVersion.

the class VelocityChannelInitializer method initChannel.

@Override
protected void initChannel(Channel channel) throws Exception {
    INIT_CHANNEL.invoke(original, channel);
    UserConnection user = new UserConnectionImpl(channel, clientSide);
    new ProtocolPipelineImpl(user);
    // We need to add a separated handler because Velocity uses pipeline().get(MINECRAFT_DECODER)
    channel.pipeline().addBefore(MINECRAFT_ENCODER, VIA_ENCODER, new VelocityEncodeHandler(user));
    channel.pipeline().addBefore(MINECRAFT_DECODER, VIA_DECODER, new VelocityDecodeHandler(user));
}
Also used : UserConnectionImpl(com.viaversion.viaversion.connection.UserConnectionImpl) ProtocolPipelineImpl(com.viaversion.viaversion.protocol.ProtocolPipelineImpl) UserConnection(com.viaversion.viaversion.api.connection.UserConnection)

Example 19 with UserConnectionImpl

use of com.viaversion.viaversion.connection.UserConnectionImpl in project ViaVersion by ViaVersion.

the class SpongeChannelInitializer method initChannel.

@Override
protected void initChannel(Channel channel) throws Exception {
    // Ensure ViaVersion is loaded
    if (Via.getAPI().getServerVersion().isKnown() && channel instanceof SocketChannel) {
        // channel can be LocalChannel on internal server
        UserConnection info = new UserConnectionImpl((SocketChannel) channel);
        // init protocol
        new ProtocolPipelineImpl(info);
        // Add originals
        INIT_CHANNEL_METHOD.invoke(this.original, channel);
        // Add our transformers
        MessageToByteEncoder encoder = new SpongeEncodeHandler(info, (MessageToByteEncoder) channel.pipeline().get("encoder"));
        ByteToMessageDecoder decoder = new SpongeDecodeHandler(info, (ByteToMessageDecoder) channel.pipeline().get("decoder"));
        channel.pipeline().replace("encoder", "encoder", encoder);
        channel.pipeline().replace("decoder", "decoder", decoder);
    } else {
        INIT_CHANNEL_METHOD.invoke(this.original, channel);
    }
}
Also used : SocketChannel(io.netty.channel.socket.SocketChannel) UserConnectionImpl(com.viaversion.viaversion.connection.UserConnectionImpl) ProtocolPipelineImpl(com.viaversion.viaversion.protocol.ProtocolPipelineImpl) ByteToMessageDecoder(io.netty.handler.codec.ByteToMessageDecoder) UserConnection(com.viaversion.viaversion.api.connection.UserConnection) MessageToByteEncoder(io.netty.handler.codec.MessageToByteEncoder)

Example 20 with UserConnectionImpl

use of com.viaversion.viaversion.connection.UserConnectionImpl in project ViaVersion by ViaVersion.

the class BukkitChannelInitializer method afterChannelInitialize.

public static void afterChannelInitialize(Channel channel) {
    UserConnection connection = new UserConnectionImpl(channel);
    new ProtocolPipelineImpl(connection);
    if (PaperViaInjector.PAPER_PACKET_LIMITER) {
        connection.setPacketLimiterEnabled(false);
    }
    // Add our transformers
    HandlerConstructor constructor = ClassGenerator.getConstructor();
    MessageToByteEncoder encoder = constructor.newEncodeHandler(connection, (MessageToByteEncoder) channel.pipeline().get("encoder"));
    ByteToMessageDecoder decoder = constructor.newDecodeHandler(connection, (ByteToMessageDecoder) channel.pipeline().get("decoder"));
    channel.pipeline().replace("encoder", "encoder", encoder);
    channel.pipeline().replace("decoder", "decoder", decoder);
}
Also used : UserConnectionImpl(com.viaversion.viaversion.connection.UserConnectionImpl) HandlerConstructor(com.viaversion.viaversion.classgenerator.generated.HandlerConstructor) ProtocolPipelineImpl(com.viaversion.viaversion.protocol.ProtocolPipelineImpl) ByteToMessageDecoder(io.netty.handler.codec.ByteToMessageDecoder) UserConnection(com.viaversion.viaversion.api.connection.UserConnection) MessageToByteEncoder(io.netty.handler.codec.MessageToByteEncoder)

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