Rework states, fixed children, and storage logic [stage]

This commit is contained in:
crschnick
2023-08-05 10:13:17 +00:00
parent 5c6b98fd14
commit b0881a2909
21 changed files with 229 additions and 118 deletions
@@ -276,24 +276,6 @@ public class BeaconClient implements AutoCloseable {
return out;
}
@FunctionalInterface
public interface FailableBiConsumer<T, U, E extends Throwable> {
void accept(T var1, U var2) throws E;
}
@FunctionalInterface
public interface FailableConsumer<T, E extends Throwable> {
void accept(T var1) throws E;
}
@FunctionalInterface
public interface FailableRunnable<E extends Throwable> {
void run() throws E;
}
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
public abstract static class ClientInformation {
@@ -4,6 +4,8 @@ import io.xpipe.beacon.exchange.WriteStreamExchange;
import io.xpipe.beacon.exchange.cli.StoreAddExchange;
import io.xpipe.beacon.util.QuietDialogHandler;
import io.xpipe.core.impl.InternalStreamStore;
import io.xpipe.core.util.FailableBiConsumer;
import io.xpipe.core.util.FailableConsumer;
import java.io.IOException;
import java.io.InputStream;
@@ -35,7 +37,7 @@ public abstract class BeaconConnection implements AutoCloseable {
}
}
public void withOutputStream(BeaconClient.FailableConsumer<OutputStream, IOException> ex) {
public void withOutputStream(FailableConsumer<OutputStream, IOException> ex) {
try {
ex.accept(getOutputStream());
} catch (IOException e) {
@@ -43,7 +45,7 @@ public abstract class BeaconConnection implements AutoCloseable {
}
}
public void withInputStream(BeaconClient.FailableConsumer<InputStream, IOException> ex) {
public void withInputStream(FailableConsumer<InputStream, IOException> ex) {
try {
ex.accept(getInputStream());
} catch (IOException e) {
@@ -78,7 +80,7 @@ public abstract class BeaconConnection implements AutoCloseable {
}
public <REQ extends RequestMessage, RES extends ResponseMessage> void performInputExchange(
REQ req, BeaconClient.FailableBiConsumer<RES, InputStream, Exception> responseConsumer) {
REQ req, FailableBiConsumer<RES, InputStream, Exception> responseConsumer) {
checkClosed();
performInputOutputExchange(req, null, responseConsumer);
@@ -86,8 +88,8 @@ public abstract class BeaconConnection implements AutoCloseable {
public <REQ extends RequestMessage, RES extends ResponseMessage> void performInputOutputExchange(
REQ req,
BeaconClient.FailableConsumer<OutputStream, IOException> reqWriter,
BeaconClient.FailableBiConsumer<RES, InputStream, Exception> responseConsumer) {
FailableConsumer<OutputStream, IOException> reqWriter,
FailableBiConsumer<RES, InputStream, Exception> responseConsumer) {
checkClosed();
try {
@@ -149,7 +151,7 @@ public abstract class BeaconConnection implements AutoCloseable {
}
public <REQ extends RequestMessage, RES extends ResponseMessage> RES performOutputExchange(
REQ req, BeaconClient.FailableConsumer<OutputStream, Exception> reqWriter) {
REQ req, FailableConsumer<OutputStream, Exception> reqWriter) {
checkClosed();
try {
@@ -1,5 +1,7 @@
package io.xpipe.beacon;
import io.xpipe.core.util.FailableRunnable;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -14,7 +16,7 @@ public interface BeaconHandler {
*
* @param r the runnable to execute
*/
void postResponse(BeaconClient.FailableRunnable<Exception> r);
void postResponse(FailableRunnable<Exception> r);
/**
* Prepares to attach a body to a response.