mirror of https://github.com/FOME-Tech/fome-fw.git
proxy progress - I am getting tired :(
This commit is contained in:
parent
fa328e8874
commit
64ec3d2f4d
|
@ -76,7 +76,8 @@ public class BinaryProtocolServer implements BinaryProtocolCommands {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts a new thread
|
* Starts a new thread
|
||||||
* @param port server port to accept connections
|
*
|
||||||
|
* @param port server port to accept connections
|
||||||
* @param threadName
|
* @param threadName
|
||||||
* @param socketRunnableFactory method to invoke on a new thread for each new client connection
|
* @param socketRunnableFactory method to invoke on a new thread for each new client connection
|
||||||
* @param logger
|
* @param logger
|
||||||
|
@ -101,15 +102,17 @@ public class BinaryProtocolServer implements BinaryProtocolCommands {
|
||||||
if (serverSocketCreationCallback != null)
|
if (serverSocketCreationCallback != null)
|
||||||
serverSocketCreationCallback.onResult(null);
|
serverSocketCreationCallback.onResult(null);
|
||||||
Runnable runnable = () -> {
|
Runnable runnable = () -> {
|
||||||
try {
|
while (!holder.isClosed()) {
|
||||||
while (!holder.isClosed()) {
|
// Wait for a connection
|
||||||
// Wait for a connection
|
final Socket clientSocket;
|
||||||
final Socket clientSocket = serverSocket.accept();
|
try {
|
||||||
logger.info("Binary protocol proxy port connection");
|
clientSocket = serverSocket.accept();
|
||||||
new Thread(clientSocketRunnableFactory.apply(clientSocket), "proxy connection").start();
|
} catch (IOException e) {
|
||||||
|
logger.info("Client socket closed right away" + e);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
logger.info("Binary protocol proxy port connection");
|
||||||
throw new IllegalStateException(e);
|
new Thread(clientSocketRunnableFactory.apply(clientSocket), "proxy connection").start();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
new Thread(runnable, threadName).start();
|
new Thread(runnable, threadName).start();
|
||||||
|
|
|
@ -84,7 +84,7 @@ public class FullServerTest {
|
||||||
|
|
||||||
// start authenticator
|
// start authenticator
|
||||||
int authenticatorPort = 7004; // local port on which authenticator accepts connections from Tuner Studio
|
int authenticatorPort = 7004; // local port on which authenticator accepts connections from Tuner Studio
|
||||||
LocalApplicationProxy.startAndRun(logger, serverPortForRemoteUsers, applicationRequest, authenticatorPort, httpPort);
|
LocalApplicationProxy.startAndRun(logger, serverPortForRemoteUsers, applicationRequest, authenticatorPort, httpPort, TcpIoStream.DisconnectListener.VOID);
|
||||||
|
|
||||||
|
|
||||||
CountDownLatch connectionEstablishedCountDownLatch = new CountDownLatch(1);
|
CountDownLatch connectionEstablishedCountDownLatch = new CountDownLatch(1);
|
||||||
|
|
|
@ -5,6 +5,8 @@ import com.rusefi.LocalApplicationProxy;
|
||||||
import com.rusefi.NamedThreadFactory;
|
import com.rusefi.NamedThreadFactory;
|
||||||
import com.rusefi.SignatureHelper;
|
import com.rusefi.SignatureHelper;
|
||||||
import com.rusefi.autoupdate.AutoupdateUtil;
|
import com.rusefi.autoupdate.AutoupdateUtil;
|
||||||
|
import com.rusefi.io.tcp.ServerHolder;
|
||||||
|
import com.rusefi.io.tcp.TcpIoStream;
|
||||||
import com.rusefi.server.ApplicationRequest;
|
import com.rusefi.server.ApplicationRequest;
|
||||||
import com.rusefi.server.ControllerInfo;
|
import com.rusefi.server.ControllerInfo;
|
||||||
import com.rusefi.server.SessionDetails;
|
import com.rusefi.server.SessionDetails;
|
||||||
|
@ -21,6 +23,7 @@ import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
||||||
|
|
||||||
|
@ -72,7 +75,7 @@ public class RemoteTab {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getLocalPort() {
|
private String getLocalPort() {
|
||||||
return getConfig().getRoot().getProperty(APPLICATION_PORT, "8100");
|
return getConfig().getRoot().getProperty(APPLICATION_PORT, "29001");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void requestListDownload() {
|
private void requestListDownload() {
|
||||||
|
@ -142,11 +145,21 @@ public class RemoteTab {
|
||||||
ApplicationRequest applicationRequest = new ApplicationRequest(sessionDetails, publicSession.getUserDetails().getUserId());
|
ApplicationRequest applicationRequest = new ApplicationRequest(sessionDetails, publicSession.getUserDetails().getUserId());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
LocalApplicationProxy.startAndRun(Logger.CONSOLE,
|
AtomicReference<ServerHolder> serverHolderAtomicReference = new AtomicReference<>();
|
||||||
|
|
||||||
|
TcpIoStream.DisconnectListener disconnectListener = () -> SwingUtilities.invokeLater(() -> {
|
||||||
|
setStatus("Disconnected");
|
||||||
|
ServerHolder serverHolder = serverHolderAtomicReference.get();
|
||||||
|
if (serverHolder != null)
|
||||||
|
serverHolder.close();
|
||||||
|
});
|
||||||
|
|
||||||
|
ServerHolder serverHolder = LocalApplicationProxy.startAndRun(Logger.CONSOLE,
|
||||||
LocalApplicationProxy.SERVER_PORT_FOR_APPLICATIONS,
|
LocalApplicationProxy.SERVER_PORT_FOR_APPLICATIONS,
|
||||||
applicationRequest,
|
applicationRequest,
|
||||||
Integer.parseInt(getLocalPort()),
|
Integer.parseInt(getLocalPort()),
|
||||||
HttpUtil.PROXY_JSON_API_HTTP_PORT, () -> SwingUtilities.invokeLater(() -> setStatus("Disconnected")));
|
HttpUtil.PROXY_JSON_API_HTTP_PORT, disconnectListener);
|
||||||
|
serverHolderAtomicReference.set(serverHolder);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
setStatus("IO error: " + e);
|
setStatus("IO error: " + e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue