proxy progress - I am getting tired :(
This commit is contained in:
parent
1701a221a4
commit
260c7a7786
|
@ -76,7 +76,8 @@ public class BinaryProtocolServer implements BinaryProtocolCommands {
|
|||
|
||||
/**
|
||||
* Starts a new thread
|
||||
* @param port server port to accept connections
|
||||
*
|
||||
* @param port server port to accept connections
|
||||
* @param threadName
|
||||
* @param socketRunnableFactory method to invoke on a new thread for each new client connection
|
||||
* @param logger
|
||||
|
@ -101,15 +102,17 @@ public class BinaryProtocolServer implements BinaryProtocolCommands {
|
|||
if (serverSocketCreationCallback != null)
|
||||
serverSocketCreationCallback.onResult(null);
|
||||
Runnable runnable = () -> {
|
||||
try {
|
||||
while (!holder.isClosed()) {
|
||||
// Wait for a connection
|
||||
final Socket clientSocket = serverSocket.accept();
|
||||
logger.info("Binary protocol proxy port connection");
|
||||
new Thread(clientSocketRunnableFactory.apply(clientSocket), "proxy connection").start();
|
||||
while (!holder.isClosed()) {
|
||||
// Wait for a connection
|
||||
final Socket clientSocket;
|
||||
try {
|
||||
clientSocket = serverSocket.accept();
|
||||
} catch (IOException e) {
|
||||
logger.info("Client socket closed right away" + e);
|
||||
continue;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException(e);
|
||||
logger.info("Binary protocol proxy port connection");
|
||||
new Thread(clientSocketRunnableFactory.apply(clientSocket), "proxy connection").start();
|
||||
}
|
||||
};
|
||||
new Thread(runnable, threadName).start();
|
||||
|
|
|
@ -84,7 +84,7 @@ public class FullServerTest {
|
|||
|
||||
// start authenticator
|
||||
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);
|
||||
|
|
|
@ -5,6 +5,8 @@ import com.rusefi.LocalApplicationProxy;
|
|||
import com.rusefi.NamedThreadFactory;
|
||||
import com.rusefi.SignatureHelper;
|
||||
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.ControllerInfo;
|
||||
import com.rusefi.server.SessionDetails;
|
||||
|
@ -21,6 +23,7 @@ import java.io.IOException;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import static com.rusefi.ui.storage.PersistentConfiguration.getConfig;
|
||||
|
||||
|
@ -72,7 +75,7 @@ public class RemoteTab {
|
|||
}
|
||||
|
||||
private String getLocalPort() {
|
||||
return getConfig().getRoot().getProperty(APPLICATION_PORT, "8100");
|
||||
return getConfig().getRoot().getProperty(APPLICATION_PORT, "29001");
|
||||
}
|
||||
|
||||
private void requestListDownload() {
|
||||
|
@ -142,11 +145,21 @@ public class RemoteTab {
|
|||
ApplicationRequest applicationRequest = new ApplicationRequest(sessionDetails, publicSession.getUserDetails().getUserId());
|
||||
|
||||
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,
|
||||
applicationRequest,
|
||||
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) {
|
||||
setStatus("IO error: " + e);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue