proxy progress

This commit is contained in:
rusefi 2020-07-30 20:34:21 -04:00
parent 2e10859205
commit 695907918f
4 changed files with 7 additions and 6 deletions

View File

@ -34,7 +34,7 @@ public class BinaryProtocolProxy {
TcpIoStream clientStream = null;
try {
clientStream = new TcpIoStream("[[proxy]] ", clientSocket);
runProxy(targetEcuSocket, clientStream, relayCommandCounter);
runProxy(targetEcuSocket, clientStream, relayCommandCounter, USER_IO_TIMEOUT);
} catch (IOException e) {
log.error("BinaryProtocolProxy::run " + e);
close(clientStream);
@ -43,12 +43,12 @@ public class BinaryProtocolProxy {
return BinaryProtocolServer.tcpServerSocket(serverProxyPort, "proxy", clientSocketRunnableFactory, Listener.empty());
}
public static void runProxy(IoStream targetEcu, IoStream clientStream, AtomicInteger relayCommandCounter) throws IOException {
public static void runProxy(IoStream targetEcu, IoStream clientStream, AtomicInteger relayCommandCounter, int timeoutMs) throws IOException {
/*
* Each client socket is running on it's own thread
*/
while (!targetEcu.isClosed()) {
byte firstByte = clientStream.getDataBuffer().readByte(USER_IO_TIMEOUT);
byte firstByte = clientStream.getDataBuffer().readByte(timeoutMs);
if (firstByte == COMMAND_PROTOCOL) {
clientStream.write(TS_PROTOCOL.getBytes());
continue;

View File

@ -63,6 +63,7 @@ public class TcpIoStream extends AbstractIoStream {
@Override
public void write(byte[] bytes) throws IOException {
super.write(bytes);
output.write(bytes);
}

View File

@ -204,7 +204,7 @@ public class Backend implements Closeable {
applications.add(applicationConnectionState);
}
BinaryProtocolProxy.runProxy(state.getStream(), applicationClientStream, new AtomicInteger());
BinaryProtocolProxy.runProxy(state.getStream(), applicationClientStream, new AtomicInteger(), BinaryProtocolProxy.USER_IO_TIMEOUT);
} catch (Throwable e) {
log.info("Application Connector: Got error " + e);

View File

@ -153,7 +153,7 @@ public class RemoteTab {
bottomPanel.add(new JLabel(" Used by " + publicSession.getOwnerName()));
} else {
JButton connect = new JButton("Connect to " + publicSession.getUserDetails().getUserName());
connect.addActionListener(event -> connecToToProxy(publicSession, controllerInfo));
connect.addActionListener(event -> connectToProxy(publicSession, controllerInfo));
bottomPanel.add(connect);
}
@ -168,7 +168,7 @@ public class RemoteTab {
return userPanel;
}
private void connecToToProxy(PublicSession publicSession, ControllerInfo controllerInfo) {
private void connectToProxy(PublicSession publicSession, ControllerInfo controllerInfo) {
RemoteTabController.INSTANCE.setState(RemoteTabController.State.CONNECTING);
setStatus("Connecting to " + publicSession.getUserDetails().getUserName());