proxy progress - getting REALLY close?!
This commit is contained in:
parent
31363ccb77
commit
4d5cbb2534
|
@ -2,6 +2,7 @@ package com.rusefi.io;
|
|||
|
||||
import com.opensr5.Logger;
|
||||
import com.opensr5.io.DataListener;
|
||||
import com.rusefi.config.generated.Fields;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
@ -25,7 +26,7 @@ public interface ByteReader {
|
|||
Thread.currentThread().setName("TCP connector loop");
|
||||
logger.info(loggingPrefix + "Running TCP connection loop");
|
||||
|
||||
byte inputBuffer[] = new byte[256];
|
||||
byte inputBuffer[] = new byte[Fields.BLOCKING_FACTOR * 2];
|
||||
while (true) {
|
||||
try {
|
||||
int result = reader.read(inputBuffer);
|
||||
|
|
|
@ -6,6 +6,8 @@ import org.apache.http.HttpResponse;
|
|||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.params.HttpConnectionParams;
|
||||
import org.apache.http.params.HttpParams;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
|
@ -40,6 +42,11 @@ public class HttpUtil {
|
|||
|
||||
public static HttpResponse executeGet(Logger logger, String url) throws IOException {
|
||||
HttpClient httpclient = new DefaultHttpClient();
|
||||
HttpParams httpParameters = httpclient.getParams();
|
||||
// HttpConnectionParams.setConnectionTimeout(httpParameters, CONNECTION_TIMEOUT);
|
||||
// HttpConnectionParams.setSoTimeout(httpParameters, WAIT_RESPONSE_TIMEOUT);
|
||||
// without this magic http response is pretty slow
|
||||
HttpConnectionParams.setTcpNoDelay(httpParameters, true);
|
||||
logger.info("GET " + url);
|
||||
HttpGet httpget = new HttpGet(url);
|
||||
return httpclient.execute(httpget);
|
||||
|
|
|
@ -112,21 +112,18 @@ public class RemoteTab {
|
|||
JButton connect = new JButton("Connect");
|
||||
connect.addActionListener(event -> {
|
||||
|
||||
SessionDetails sessionDetails = new SessionDetails(controllerInfo, AuthTokenPanel.getAuthToken(),
|
||||
Integer.parseInt(oneTimePasswordControl.getText()));
|
||||
list.removeAll();
|
||||
list.add(new JLabel("Connecting to " + publicSession.getUserDetails().getUserName()));
|
||||
AutoupdateUtil.trueLayout(list);
|
||||
|
||||
ApplicationRequest applicationRequest = new ApplicationRequest(sessionDetails, publicSession.getUserDetails().getUserId());
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
runAuthenticator(publicSession, controllerInfo);
|
||||
|
||||
}
|
||||
}, "Authenticator").start();
|
||||
|
||||
try {
|
||||
LocalApplicationProxy.startAndRun(Logger.CONSOLE,
|
||||
LocalApplicationProxy.SERVER_PORT_FOR_APPLICATIONS,
|
||||
applicationRequest,
|
||||
Integer.parseInt(getLocalPort()),
|
||||
HttpUtil.PROXY_JSON_API_HTTP_PORT);
|
||||
} catch (IOException e) {
|
||||
// todo: proper handling
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
});
|
||||
userPanel.add(connect);
|
||||
|
@ -134,6 +131,24 @@ public class RemoteTab {
|
|||
return userPanel;
|
||||
}
|
||||
|
||||
private void runAuthenticator(PublicSession publicSession, ControllerInfo controllerInfo) {
|
||||
SessionDetails sessionDetails = new SessionDetails(controllerInfo, AuthTokenPanel.getAuthToken(),
|
||||
Integer.parseInt(oneTimePasswordControl.getText()));
|
||||
|
||||
ApplicationRequest applicationRequest = new ApplicationRequest(sessionDetails, publicSession.getUserDetails().getUserId());
|
||||
|
||||
try {
|
||||
LocalApplicationProxy.startAndRun(Logger.CONSOLE,
|
||||
LocalApplicationProxy.SERVER_PORT_FOR_APPLICATIONS,
|
||||
applicationRequest,
|
||||
Integer.parseInt(getLocalPort()),
|
||||
HttpUtil.PROXY_JSON_API_HTTP_PORT);
|
||||
} catch (IOException e) {
|
||||
// todo: proper handling
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public JComponent getContent() {
|
||||
return content;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue