// Path: Java/Blink/library/src/net/qiujuer/blink/BlinkClient.java
// public class BlinkClient extends BlinkConnect {
//     private SocketAddress mAddress;
// 
//     public BlinkClient() {
//         setDelivery(new ExecutorDelivery(null));
//     }
// 
//     public boolean connect(String ip, int port) {
//         return connect(new InetSocketAddress(ip, port));
//     }
// 
//     public boolean connect(InetSocketAddress address) {
//         return connect((SocketAddress) address);
//     }
// 
//     public boolean connect(SocketAddress address) {
//         mAddress = address;
//         try {
//             SocketChannel channel = SocketChannel.open(mAddress);
//             boolean connected = channel.isConnected();
//             if (connected) {
//                 channel.configureBlocking(false);
//                 start(channel);
//             }
//             return connected;
//         } catch (IOException e) {
//             e.printStackTrace();
//             return false;
//         }
//     }
// 
//     public boolean reconnect() {
//         if (mAddress == null)
//             throw new NullPointerException("SocketChannel address is null, you should call connect.");
// 
//         dispose();
// 
//         return connect(mAddress);
//     }
// }
// 
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/core/SendPacket.java
// public abstract class SendPacket extends BlinkPacket {
//     private final SendListener mListener;
//     private boolean mCanceled;
//     private BlinkConn mBlinkConn;
// 
// 
//     public SendPacket(byte type, SendListener listener) {
//         super(type);
//         mListener = listener;
//     }
// 
//     public SendListener getListener() {
//         return mListener;
//     }
// 
//     /**
//      * Cancel the packet to send
//      * If the packet on sending you can't cancel it
//      * But you can cancel sending notify callback
//      */
//     public void cancel() {
//         mCanceled = true;
//         if (mBlinkConn != null) {
//             mBlinkConn.cancel(this);
//             mBlinkConn = null;
//         }
//     }
// 
//     /**
//      * Get the packet iscanceled
//      *
//      * @return Is Canceled
//      */
//     public boolean isCanceled() {
//         return mCanceled;
//     }
// 
//     /**
//      * Set The BlinkConn to Cancel from queue
//      *
//      * @param blinkConn BlinkConn
//      * @return SendPacket
//      */
//     SendPacket setBlinkConn(BlinkConn blinkConn) {
//         mBlinkConn = blinkConn;
//         return this;
//     }
// 
//     /**
//      * On Sender send the packet call this to send packet info
//      * The bytes in 0~32767 size
//      *
//      * @param buffer Send buffer
//      * @param index  Buffer start index
//      * @return Read to buffer count
//      */
//     public short readInfo(byte[] buffer, int index) {
//         return 0;
//     }
// 
//     /**
//      * Sender read same data to send
//      *
//      * @param buffer Buffer
//      * @param offset Buffer offset
//      * @param count  Buffer count
//      * @return Read to buffer count
//      */
//     public abstract int read(byte[] buffer, int offset, int count);
// }
// 
// Path: Java/Blink/library/src/net/qiujuer/blink/core/listener/SendListener.java
// public interface SendListener {
// 
//     /**
//      * On start send the packet call
//      *
//      * @param packet SendPacket
//      */
//     void onSendStart(SendPacket packet);
// 
// 
//     /**
//      * On the packet send progress changed call
//      *
//      * @param packet   SendPacket
//      * @param progress Progress (0~1)
//      */
//     void onSendProgress(SendPacket packet, float progress);
// 
//     /**
//      * On send completed call
//      *
//      * @param packet SendPacket
//      */
//     void onSendCompleted(SendPacket packet);
// }


import net.qiujuer.blink.BlinkClient;
import net.qiujuer.blink.core.SendPacket;
import net.qiujuer.blink.core.listener.SendListener;
import java.io.File;
import java.io.IOException;
package net.qiujuer.sample.blink;



/**
 * Blink Client
 */
public class Client {
    private static void send(BlinkClient connect) {
        System.out.println("Client Sending...");

        System.out.println("Send Some String.");
        for (int i = 0; i <= 50; i++) {
            connect.send("Blink String:" + i);
        }

        System.out.println("Send Some Bytes.");
        connect.send(new byte[]{1, 1, 0, 0});
        connect.send(new byte[]{1, 1, 1, 0, 1});

        System.out.println("Send A File.(D:/Data.txt)");
        connect.send(new File("F:\\TDDOWNLOAD\\Game\\LIMBO.zip"),
                new SendListener() {
                    @Override
// Path: Java/Blink/library/src/net/qiujuer/blink/BlinkClient.java
// public class BlinkClient extends BlinkConnect {
//     private SocketAddress mAddress;
// 
//     public BlinkClient() {
//         setDelivery(new ExecutorDelivery(null));
//     }
// 
//     public boolean connect(String ip, int port) {
//         return connect(new InetSocketAddress(ip, port));
//     }
// 
//     public boolean connect(InetSocketAddress address) {
//         return connect((SocketAddress) address);
//     }
// 
//     public boolean connect(SocketAddress address) {
//         mAddress = address;
//         try {
//             SocketChannel channel = SocketChannel.open(mAddress);
//             boolean connected = channel.isConnected();
//             if (connected) {
//                 channel.configureBlocking(false);
//                 start(channel);
//             }
//             return connected;
//         } catch (IOException e) {
//             e.printStackTrace();
//             return false;
//         }
//     }
// 
//     public boolean reconnect() {
//         if (mAddress == null)
//             throw new NullPointerException("SocketChannel address is null, you should call connect.");
// 
//         dispose();
// 
//         return connect(mAddress);
//     }
// }
// 
// Path: Android/Blink/library/src/main/java/net/qiujuer/blink/core/SendPacket.java
// public abstract class SendPacket extends BlinkPacket {
//     private final SendListener mListener;
//     private boolean mCanceled;
//     private BlinkConn mBlinkConn;
// 
// 
//     public SendPacket(byte type, SendListener listener) {
//         super(type);
//         mListener = listener;
//     }
// 
//     public SendListener getListener() {
//         return mListener;
//     }
// 
//     /**
//      * Cancel the packet to send
//      * If the packet on sending you can't cancel it
//      * But you can cancel sending notify callback
//      */
//     public void cancel() {
//         mCanceled = true;
//         if (mBlinkConn != null) {
//             mBlinkConn.cancel(this);
//             mBlinkConn = null;
//         }
//     }
// 
//     /**
//      * Get the packet iscanceled
//      *
//      * @return Is Canceled
//      */
//     public boolean isCanceled() {
//         return mCanceled;
//     }
// 
//     /**
//      * Set The BlinkConn to Cancel from queue
//      *
//      * @param blinkConn BlinkConn
//      * @return SendPacket
//      */
//     SendPacket setBlinkConn(BlinkConn blinkConn) {
//         mBlinkConn = blinkConn;
//         return this;
//     }
// 
//     /**
//      * On Sender send the packet call this to send packet info
//      * The bytes in 0~32767 size
//      *
//      * @param buffer Send buffer
//      * @param index  Buffer start index
//      * @return Read to buffer count
//      */
//     public short readInfo(byte[] buffer, int index) {
//         return 0;
//     }
// 
//     /**
//      * Sender read same data to send
//      *
//      * @param buffer Buffer
//      * @param offset Buffer offset
//      * @param count  Buffer count
//      * @return Read to buffer count
//      */
//     public abstract int read(byte[] buffer, int offset, int count);
// }
// 
// Path: Java/Blink/library/src/net/qiujuer/blink/core/listener/SendListener.java
// public interface SendListener {
// 
//     /**
//      * On start send the packet call
//      *
//      * @param packet SendPacket
//      */
//     void onSendStart(SendPacket packet);
// 
// 
//     /**
//      * On the packet send progress changed call
//      *
//      * @param packet   SendPacket
//      * @param progress Progress (0~1)
//      */
//     void onSendProgress(SendPacket packet, float progress);
// 
//     /**
//      * On send completed call
//      *
//      * @param packet SendPacket
//      */
//     void onSendCompleted(SendPacket packet);
// }


// Path: Java/Blink/sample/src/net/qiujuer/sample/blink/Client.java
import net.qiujuer.blink.BlinkClient;
import net.qiujuer.blink.core.SendPacket;
import net.qiujuer.blink.core.listener.SendListener;
import java.io.File;
import java.io.IOException;

package net.qiujuer.sample.blink;



/**
 * Blink Client
 */
public class Client {
    private static void send(BlinkClient connect) {
        System.out.println("Client Sending...");

        System.out.println("Send Some String.");
        for (int i = 0; i <= 50; i++) {
            connect.send("Blink String:" + i);
        }

        System.out.println("Send Some Bytes.");
        connect.send(new byte[]{1, 1, 0, 0});
        connect.send(new byte[]{1, 1, 1, 0, 1});

        System.out.println("Send A File.(D:/Data.txt)");
        connect.send(new File("F:\\TDDOWNLOAD\\Game\\LIMBO.zip"),
                new SendListener() {
                    @Override
                    public void onSendStart(SendPacket packet) {