package me.lorinlee.network;

import me.lorinlee.request.Request;

import java.io.IOException;

/**
 * Created by lorin on 17-5-22.
 */
public class RequestSocket extends CommonSocket {

    private boolean status = true;

    private static class RequestSocketHolder {
        private final static RequestSocket REQUEST_SOCKET = new RequestSocket();
    }

    public static RequestSocket getInstance() {
        return RequestSocketHolder.REQUEST_SOCKET;
    }

    public void sendRequest(Request request) {
        try {
            bufferedWriter.write(request.toString());
            bufferedWriter.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public boolean isStatus() {
        return status;
    }

    public void setStatus(boolean status) {
        this.status = status;
    }
}

@@ -87,16 +87,49 @@
 ception;
+%0Aimport java.net.SocketException;
 %0A%0A/**%0A *
@@ -213,16 +213,122 @@
 cket %7B%0A%0A
+    private static final int SHORT_READ_MODE = 200;%0A    private static final int LONG_READ_MODE = 10000;%0A%0A
     priv
@@ -972,11 +972,334 @@
 s;%0A    %7D
+%0A%0A    public void setShortReadMode() throws SocketException %7B%0A        socket.setSoTimeout(SHORT_READ_MODE);%0A    %7D%0A%0A    public void setLongReadMode() throws SocketException %7B%0A        socket.setSoTimeout(LONG_READ_MODE);%0A    %7D%0A%0A    public String readLine() throws IOException %7B%0A        return bufferedReader.readLine();%0A    %7D
 %0A%7D%0A

add request socket change timeout