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));
}
}
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));
}
}
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));
}
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);
}
}
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);
}
Aggregations