// Path: dragonite-sdk/src/main/java/com/vecsight/dragonite/sdk/misc/DragoniteGlobalConstants.java
// public final class DragoniteGlobalConstants {
// 
//     public static final String LIBRARY_VERSION = DragoniteBuildConfig.VERSION;
// 
//     public static final byte PROTOCOL_VERSION = 2;
// 
//     public static final int MIN_SEND_WINDOW_SIZE = 20;
// 
//     public static final int ACK_INTERVAL_MS = 10;
// 
//     public static final int MAX_FAST_RESEND_COUNT = 3;
// 
//     public static final int MAX_SLOW_RESEND_MULT = 4;
// 
//     public static final int INIT_RTT_MS = 200, RTT_MAX_VARIATION_MS = 200, RTT_UPDATE_INTERVAL_MS = 100, RTT_RESEND_CORRECTION_INTERVAL_MS = 2000;
// 
//     public static final int DEV_RTT_MULT = 4;
// 
//     public static final float RTT_RESENDED_REFRESH_MAX_MULT = 1.5f;
// 
//     public static final int MIN_CLOSE_WAIT_MS = 100, CLOSE_WAIT_RTT_MULT = 4;
// 
//     public static final int WEB_PANEL_PORT = 8000;
// 
// }
// 
// Path: dragonite-sdk/src/main/java/com/vecsight/dragonite/sdk/misc/NumUtils.java
// public final class NumUtils {
// 
//     public static long min(final long l1, final long l2) {
//         return l1 < l2 ? l1 : l2;
//     }
// 
//     public static long max(final long l1, final long l2) {
//         return l1 > l2 ? l1 : l2;
//     }
// 
//     public static int min(final int i1, final int i2) {
//         return i1 < i2 ? i1 : i2;
//     }
// 
//     public static int max(final int i1, final int i2) {
//         return i1 > i2 ? i1 : i2;
//     }
// 
// }
// 
// Path: dragonite-sdk/src/main/java/com/vecsight/dragonite/sdk/msg/ReliableMessage.java
// public interface ReliableMessage extends Message {
// 
//     int getSequence();
// 
//     void setSequence(int sequence);
// 
// }


import com.vecsight.dragonite.sdk.misc.DragoniteGlobalConstants;
import com.vecsight.dragonite.sdk.misc.NumUtils;
import com.vecsight.dragonite.sdk.msg.ReliableMessage;
import java.io.IOException;
import java.util.PriorityQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicLong;
                    if (sleepTime > 0) {
                        Thread.sleep(sleepTime);
                    }
                    //sleep done
                    final ReliableMessage message = messageConcurrentMap.get(sequence);

                    if (message != null) {
                        try {
                            resendItem.setResended();
                            packetSender.sendPacket(message.toBytes());
                            resendCount++;
                            //System.out.println(message.getSequence());
                        } catch (final IOException ignored) {
                        }
                    }

                }
            } catch (final InterruptedException ignored) {
                //okay
            }
        }, "DS-Resend");
        resendThread.start();
    }

    private boolean canRun() {
        return running && socket.isAlive();
    }

    private long getNextSendTime(final int count, final long timeOffset) {
        final int resendMult = count <= DragoniteGlobalConstants.MAX_FAST_RESEND_COUNT ? 1 :
// Path: dragonite-sdk/src/main/java/com/vecsight/dragonite/sdk/misc/DragoniteGlobalConstants.java
// public final class DragoniteGlobalConstants {
// 
//     public static final String LIBRARY_VERSION = DragoniteBuildConfig.VERSION;
// 
//     public static final byte PROTOCOL_VERSION = 2;
// 
//     public static final int MIN_SEND_WINDOW_SIZE = 20;
// 
//     public static final int ACK_INTERVAL_MS = 10;
// 
//     public static final int MAX_FAST_RESEND_COUNT = 3;
// 
//     public static final int MAX_SLOW_RESEND_MULT = 4;
// 
//     public static final int INIT_RTT_MS = 200, RTT_MAX_VARIATION_MS = 200, RTT_UPDATE_INTERVAL_MS = 100, RTT_RESEND_CORRECTION_INTERVAL_MS = 2000;
// 
//     public static final int DEV_RTT_MULT = 4;
// 
//     public static final float RTT_RESENDED_REFRESH_MAX_MULT = 1.5f;
// 
//     public static final int MIN_CLOSE_WAIT_MS = 100, CLOSE_WAIT_RTT_MULT = 4;
// 
//     public static final int WEB_PANEL_PORT = 8000;
// 
// }
// 
// Path: dragonite-sdk/src/main/java/com/vecsight/dragonite/sdk/misc/NumUtils.java
// public final class NumUtils {
// 
//     public static long min(final long l1, final long l2) {
//         return l1 < l2 ? l1 : l2;
//     }
// 
//     public static long max(final long l1, final long l2) {
//         return l1 > l2 ? l1 : l2;
//     }
// 
//     public static int min(final int i1, final int i2) {
//         return i1 < i2 ? i1 : i2;
//     }
// 
//     public static int max(final int i1, final int i2) {
//         return i1 > i2 ? i1 : i2;
//     }
// 
// }
// 
// Path: dragonite-sdk/src/main/java/com/vecsight/dragonite/sdk/msg/ReliableMessage.java
// public interface ReliableMessage extends Message {
// 
//     int getSequence();
// 
//     void setSequence(int sequence);
// 
// }


// Path: dragonite-sdk/src/main/java/com/vecsight/dragonite/sdk/socket/ResendHandler.java
import com.vecsight.dragonite.sdk.misc.DragoniteGlobalConstants;
import com.vecsight.dragonite.sdk.misc.NumUtils;
import com.vecsight.dragonite.sdk.msg.ReliableMessage;
import java.io.IOException;
import java.util.PriorityQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicLong;

                    if (sleepTime > 0) {
                        Thread.sleep(sleepTime);
                    }
                    //sleep done
                    final ReliableMessage message = messageConcurrentMap.get(sequence);

                    if (message != null) {
                        try {
                            resendItem.setResended();
                            packetSender.sendPacket(message.toBytes());
                            resendCount++;
                            //System.out.println(message.getSequence());
                        } catch (final IOException ignored) {
                        }
                    }

                }
            } catch (final InterruptedException ignored) {
                //okay
            }
        }, "DS-Resend");
        resendThread.start();
    }

    private boolean canRun() {
        return running && socket.isAlive();
    }

    private long getNextSendTime(final int count, final long timeOffset) {
        final int resendMult = count <= DragoniteGlobalConstants.MAX_FAST_RESEND_COUNT ? 1 :
                NumUtils.min(count - DragoniteGlobalConstants.MAX_FAST_RESEND_COUNT + 1, DragoniteGlobalConstants.MAX_SLOW_RESEND_MULT);