// Path: kcp-netty/src/main/java/io/jpower/kcp/netty/UkcpChannel.java
// public interface UkcpChannel extends Channel {
// 
//     int conv();
// 
//     @Override
//     UkcpChannelConfig config();
// 
//     UkcpChannel conv(int conv);
// 
//     @Override
//     InetSocketAddress localAddress();
// 
//     @Override
//     InetSocketAddress remoteAddress();
// 
// }


import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import io.jpower.kcp.netty.UkcpChannel;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package io.jpower.kcp.example.rtt;



/**
 * @author <a href="mailto:szhnet@gmail.com">szh</a>
 */
public class KcpRttClientHandler extends ChannelInboundHandlerAdapter {

    private static final Logger log = LoggerFactory.getLogger(KcpRttClientHandler.class);

    private final ByteBuf data;

    private int[] rtts;

    private volatile int count;

    private ScheduledExecutorService scheduleSrv;

    private ScheduledFuture<?> future = null;

    private final long startTime;

    /**
     * Creates a client-side handler.
     */
    public KcpRttClientHandler(int count) {
        data = Unpooled.buffer(KcpRttClient.SIZE);
        for (int i = 0; i < data.capacity(); i++) {
            data.writeByte((byte) i);
        }

        rtts = new int[count];
        for (int i = 0; i < rtts.length; i++) {
            rtts[i] = -1;
        }
        startTime = System.currentTimeMillis();
        scheduleSrv = Executors.newSingleThreadScheduledExecutor();
    }

    @Override
    public void channelActive(final ChannelHandlerContext ctx) {
// Path: kcp-netty/src/main/java/io/jpower/kcp/netty/UkcpChannel.java
// public interface UkcpChannel extends Channel {
// 
//     int conv();
// 
//     @Override
//     UkcpChannelConfig config();
// 
//     UkcpChannel conv(int conv);
// 
//     @Override
//     InetSocketAddress localAddress();
// 
//     @Override
//     InetSocketAddress remoteAddress();
// 
// }


// Path: kcp-example/src/main/java/io/jpower/kcp/example/rtt/KcpRttClientHandler.java
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import io.jpower.kcp.netty.UkcpChannel;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

package io.jpower.kcp.example.rtt;



/**
 * @author <a href="mailto:szhnet@gmail.com">szh</a>
 */
public class KcpRttClientHandler extends ChannelInboundHandlerAdapter {

    private static final Logger log = LoggerFactory.getLogger(KcpRttClientHandler.class);

    private final ByteBuf data;

    private int[] rtts;

    private volatile int count;

    private ScheduledExecutorService scheduleSrv;

    private ScheduledFuture<?> future = null;

    private final long startTime;

    /**
     * Creates a client-side handler.
     */
    public KcpRttClientHandler(int count) {
        data = Unpooled.buffer(KcpRttClient.SIZE);
        for (int i = 0; i < data.capacity(); i++) {
            data.writeByte((byte) i);
        }

        rtts = new int[count];
        for (int i = 0; i < rtts.length; i++) {
            rtts[i] = -1;
        }
        startTime = System.currentTimeMillis();
        scheduleSrv = Executors.newSingleThreadScheduledExecutor();
    }

    @Override
    public void channelActive(final ChannelHandlerContext ctx) {
        UkcpChannel kcpCh = (UkcpChannel) ctx.channel();