Small fixes

This commit is contained in:
Christopher Schnick
2022-01-02 23:13:10 +01:00
parent 8bb6f8be3d
commit e5a84a83db
15 changed files with 120 additions and 37 deletions
@@ -6,6 +6,7 @@ import io.xpipe.beacon.message.ResponseMessage;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.util.concurrent.atomic.AtomicReference;
public abstract class BeaconConnector {
@@ -40,6 +41,10 @@ public abstract class BeaconConnector {
return response.get();
}
protected void writeLength(BeaconClient socket, int bytes) throws IOException {
socket.getOutputStream().write(ByteBuffer.allocate(4).putInt(bytes).array());
}
protected <REQ extends RequestMessage, RES extends ResponseMessage> RES performSimpleExchange(
BeaconClient socket,
REQ req) throws ServerException, ConnectorException, ClientException {
@@ -10,7 +10,7 @@ public interface BeaconHandler {
void prepareBody() throws IOException;
void startBodyRead() throws IOException;
InputStream startBodyRead() throws IOException;
public <T extends ResponseMessage> void sendResponse(T obj) throws Exception;
@@ -33,7 +33,7 @@ public class StoreResourceExchange implements MessageExchange<StoreResourceExcha
@Value
public static class Request implements RequestMessage {
URL url;
String type;
String providerId;
}
@Jacksonized
+1
View File
@@ -26,5 +26,6 @@ module io.xpipe.beacon {
ReadInfoExchange,
StatusExchange,
StopExchange,
StoreResourceExchange,
VersionExchange;
}