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

View File

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

View File

@ -204,7 +204,7 @@ public class Backend implements Closeable {
applications.add(applicationConnectionState); applications.add(applicationConnectionState);
} }
BinaryProtocolProxy.runProxy(state.getStream(), applicationClientStream, new AtomicInteger()); BinaryProtocolProxy.runProxy(state.getStream(), applicationClientStream, new AtomicInteger(), BinaryProtocolProxy.USER_IO_TIMEOUT);
} catch (Throwable e) { } catch (Throwable e) {
log.info("Application Connector: Got error " + 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())); bottomPanel.add(new JLabel(" Used by " + publicSession.getOwnerName()));
} else { } else {
JButton connect = new JButton("Connect to " + publicSession.getUserDetails().getUserName()); JButton connect = new JButton("Connect to " + publicSession.getUserDetails().getUserName());
connect.addActionListener(event -> connecToToProxy(publicSession, controllerInfo)); connect.addActionListener(event -> connectToProxy(publicSession, controllerInfo));
bottomPanel.add(connect); bottomPanel.add(connect);
} }
@ -168,7 +168,7 @@ public class RemoteTab {
return userPanel; return userPanel;
} }
private void connecToToProxy(PublicSession publicSession, ControllerInfo controllerInfo) { private void connectToProxy(PublicSession publicSession, ControllerInfo controllerInfo) {
RemoteTabController.INSTANCE.setState(RemoteTabController.State.CONNECTING); RemoteTabController.INSTANCE.setState(RemoteTabController.State.CONNECTING);
setStatus("Connecting to " + publicSession.getUserDetails().getUserName()); setStatus("Connecting to " + publicSession.getUserDetails().getUserName());