proxy progress
This commit is contained in:
parent
d20880ac2c
commit
e5ae042694
|
@ -5,6 +5,8 @@ import com.opensr5.io.DataListener;
|
||||||
import com.rusefi.binaryprotocol.IncomingDataBuffer;
|
import com.rusefi.binaryprotocol.IncomingDataBuffer;
|
||||||
import com.rusefi.io.ByteReader;
|
import com.rusefi.io.ByteReader;
|
||||||
import com.rusefi.io.serial.AbstractIoStream;
|
import com.rusefi.io.serial.AbstractIoStream;
|
||||||
|
import com.rusefi.shared.FileUtil;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -21,6 +23,8 @@ public class TcpIoStream extends AbstractIoStream {
|
||||||
private final OutputStream output;
|
private final OutputStream output;
|
||||||
private final Logger logger;
|
private final Logger logger;
|
||||||
private final String loggingPrefix;
|
private final String loggingPrefix;
|
||||||
|
@NotNull
|
||||||
|
private final Socket socket;
|
||||||
private final IncomingDataBuffer dataBuffer;
|
private final IncomingDataBuffer dataBuffer;
|
||||||
|
|
||||||
public TcpIoStream(Logger logger, Socket socket) throws IOException {
|
public TcpIoStream(Logger logger, Socket socket) throws IOException {
|
||||||
|
@ -29,11 +33,12 @@ public class TcpIoStream extends AbstractIoStream {
|
||||||
|
|
||||||
public TcpIoStream(String loggingPrefix, Logger logger, Socket socket) throws IOException {
|
public TcpIoStream(String loggingPrefix, Logger logger, Socket socket) throws IOException {
|
||||||
this.loggingPrefix = loggingPrefix;
|
this.loggingPrefix = loggingPrefix;
|
||||||
|
if (socket == null)
|
||||||
|
throw new NullPointerException("socket");
|
||||||
|
this.socket = socket;
|
||||||
InputStream input = new BufferedInputStream(socket.getInputStream());
|
InputStream input = new BufferedInputStream(socket.getInputStream());
|
||||||
OutputStream output = socket.getOutputStream();
|
OutputStream output = socket.getOutputStream();
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
if (input == null)
|
|
||||||
throw new NullPointerException("input");
|
|
||||||
if (output == null)
|
if (output == null)
|
||||||
throw new NullPointerException("output");
|
throw new NullPointerException("output");
|
||||||
this.output = output;
|
this.output = output;
|
||||||
|
@ -41,6 +46,12 @@ public class TcpIoStream extends AbstractIoStream {
|
||||||
this.dataBuffer = IncomingDataBuffer.createDataBuffer(loggingPrefix, this, logger);
|
this.dataBuffer = IncomingDataBuffer.createDataBuffer(loggingPrefix, this, logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
super.close();
|
||||||
|
FileUtil.close(socket);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getLoggingPrefix() {
|
public String getLoggingPrefix() {
|
||||||
return loggingPrefix;
|
return loggingPrefix;
|
||||||
|
|
|
@ -15,6 +15,8 @@ import java.util.List;
|
||||||
public class ProxyClient {
|
public class ProxyClient {
|
||||||
public static final String LIST_CONTROLLERS_PATH = "/list_controllers";
|
public static final String LIST_CONTROLLERS_PATH = "/list_controllers";
|
||||||
public static final String LIST_APPLICATIONS_PATH = "/list_applications";
|
public static final String LIST_APPLICATIONS_PATH = "/list_applications";
|
||||||
|
public static final String VERSION_PATH = "/version";
|
||||||
|
public static final String BACKEND_VERSION = "0.0001";
|
||||||
|
|
||||||
public static List<PublicSession> getOnlineApplications(int httpPort) throws IOException {
|
public static List<PublicSession> getOnlineApplications(int httpPort) throws IOException {
|
||||||
return getOnlineApplications(HttpUtil.RUSEFI_PROXY_JSON_API_PREFIX + ":" + httpPort + LIST_CONTROLLERS_PATH);
|
return getOnlineApplications(HttpUtil.RUSEFI_PROXY_JSON_API_PREFIX + ":" + httpPort + LIST_CONTROLLERS_PATH);
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
package com.rusefi.shared;
|
package com.rusefi.shared;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.*;
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipInputStream;
|
import java.util.zip.ZipInputStream;
|
||||||
|
|
||||||
|
@ -54,4 +51,14 @@ public class FileUtil {
|
||||||
|
|
||||||
return destFile;
|
return destFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void close(Closeable closeable) {
|
||||||
|
if (closeable != null) {
|
||||||
|
try {
|
||||||
|
closeable.close();
|
||||||
|
} catch (IOException ignored) {
|
||||||
|
// ignored
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue