// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/box/ByteSendPacket.java
// public class ByteSendPacket extends BaseSendPacket<byte[]> {
//     public ByteSendPacket(byte[] entity) {
//         this(entity, null);
//     }
// 
//     public ByteSendPacket(byte[] entity, SendListener listener) {
//         super(entity, PacketType.BYTES, listener);
//         mLength = mEntity.length;
//     }
// 
//     @Override
//     public boolean startPacket() {
//         try {
//             mStream = new ByteArrayInputStream(mEntity);
//             return true;
//         } catch (Exception e) {
//             return false;
//         }
//     }
// 
//     @Override
//     public void endPacket() {
//         closeStream();
//     }
// }
// 
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/box/FileSendPacket.java
// public class FileSendPacket extends BaseSendPacket<File> {
// 
//     public FileSendPacket(File file) {
//         this(file, null);
//     }
// 
//     public FileSendPacket(File entity, SendListener listener) {
//         super(entity, PacketType.FILE, listener);
//         mLength = mEntity.length();
//     }
// 
//     @Override
//     public boolean startPacket() {
//         try {
//             mStream = new FileInputStream(mEntity);
//             return true;
//         } catch (FileNotFoundException e) {
//             return false;
//         }
//     }
// 
//     @Override
//     public void endPacket() {
//         closeStream();
//     }
// 
//     @Override
//     public short readInfo(byte[] buffer, int index) {
//         try {
//             byte[] info = mEntity.getName().getBytes("UTF-8");
//             short len = (short) info.length;
//             System.arraycopy(info, 0, buffer, index, len);
//             return len;
//         } catch (Exception e) {
//             return 0;
//         }
//     }
// }
// 
// Path: Java/Blink/library/src/net/qiujuer/blink/box/StringSendPacket.java
// public class StringSendPacket extends ByteSendPacket {
//     public StringSendPacket(String entity) throws UnsupportedEncodingException {
//         this(entity, null);
//     }
// 
//     public StringSendPacket(String entity, SendListener listener) throws UnsupportedEncodingException {
//         super(entity.getBytes("UTF-8"), listener);
// 
//         mType = PacketType.STRING;
//     }
// }
// 
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/listener/SendListener.java
// public interface SendListener {
//     /**
//      * On sender send the packet call this
//      * On start progress == 0
//      * On end progress ==1
//      *
//      * @param progress Send progress (0~1)
//      */
//     void onSendProgress(float progress);
// }


import net.qiujuer.blink.box.ByteSendPacket;
import net.qiujuer.blink.box.FileSendPacket;
import net.qiujuer.blink.box.StringSendPacket;
import net.qiujuer.blink.listener.SendListener;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.util.concurrent.PriorityBlockingQueue;
     * @param entity SendEntity<T> {@link SendPacket}
     * @param <T>    Extends SendEntity
     * @return SendEntity<T>
     */
    public <T> SendPacket<T> send(SendPacket<T> entity) {
        entity.setBlinkConn(this);

        synchronized (mSendQueue) {
            mSendQueue.add(entity);
        }
        return entity;
    }

    /**
     * Send file to queue
     *
     * @param file File
     * @return FileSendEntity {@link FileSendPacket}
     */
    public FileSendPacket send(File file) {
        return send(file, null);
    }

    /**
     * Send file to queue
     *
     * @param file     File
     * @param listener Callback listener
     * @return FileSendEntity {@link FileSendPacket}
     */
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/box/ByteSendPacket.java
// public class ByteSendPacket extends BaseSendPacket<byte[]> {
//     public ByteSendPacket(byte[] entity) {
//         this(entity, null);
//     }
// 
//     public ByteSendPacket(byte[] entity, SendListener listener) {
//         super(entity, PacketType.BYTES, listener);
//         mLength = mEntity.length;
//     }
// 
//     @Override
//     public boolean startPacket() {
//         try {
//             mStream = new ByteArrayInputStream(mEntity);
//             return true;
//         } catch (Exception e) {
//             return false;
//         }
//     }
// 
//     @Override
//     public void endPacket() {
//         closeStream();
//     }
// }
// 
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/box/FileSendPacket.java
// public class FileSendPacket extends BaseSendPacket<File> {
// 
//     public FileSendPacket(File file) {
//         this(file, null);
//     }
// 
//     public FileSendPacket(File entity, SendListener listener) {
//         super(entity, PacketType.FILE, listener);
//         mLength = mEntity.length();
//     }
// 
//     @Override
//     public boolean startPacket() {
//         try {
//             mStream = new FileInputStream(mEntity);
//             return true;
//         } catch (FileNotFoundException e) {
//             return false;
//         }
//     }
// 
//     @Override
//     public void endPacket() {
//         closeStream();
//     }
// 
//     @Override
//     public short readInfo(byte[] buffer, int index) {
//         try {
//             byte[] info = mEntity.getName().getBytes("UTF-8");
//             short len = (short) info.length;
//             System.arraycopy(info, 0, buffer, index, len);
//             return len;
//         } catch (Exception e) {
//             return 0;
//         }
//     }
// }
// 
// Path: Java/Blink/library/src/net/qiujuer/blink/box/StringSendPacket.java
// public class StringSendPacket extends ByteSendPacket {
//     public StringSendPacket(String entity) throws UnsupportedEncodingException {
//         this(entity, null);
//     }
// 
//     public StringSendPacket(String entity, SendListener listener) throws UnsupportedEncodingException {
//         super(entity.getBytes("UTF-8"), listener);
// 
//         mType = PacketType.STRING;
//     }
// }
// 
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/listener/SendListener.java
// public interface SendListener {
//     /**
//      * On sender send the packet call this
//      * On start progress == 0
//      * On end progress ==1
//      *
//      * @param progress Send progress (0~1)
//      */
//     void onSendProgress(float progress);
// }


// Path: Android/Blink/old/src/main/java/net/qiujuer/blink/core/BlinkConn.java
import net.qiujuer.blink.box.ByteSendPacket;
import net.qiujuer.blink.box.FileSendPacket;
import net.qiujuer.blink.box.StringSendPacket;
import net.qiujuer.blink.listener.SendListener;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.util.concurrent.PriorityBlockingQueue;

     * @param entity SendEntity<T> {@link SendPacket}
     * @param <T>    Extends SendEntity
     * @return SendEntity<T>
     */
    public <T> SendPacket<T> send(SendPacket<T> entity) {
        entity.setBlinkConn(this);

        synchronized (mSendQueue) {
            mSendQueue.add(entity);
        }
        return entity;
    }

    /**
     * Send file to queue
     *
     * @param file File
     * @return FileSendEntity {@link FileSendPacket}
     */
    public FileSendPacket send(File file) {
        return send(file, null);
    }

    /**
     * Send file to queue
     *
     * @param file     File
     * @param listener Callback listener
     * @return FileSendEntity {@link FileSendPacket}
     */
    public FileSendPacket send(File file, SendListener listener) {