Rework beacon

This commit is contained in:
Christopher Schnick
2021-12-13 15:29:04 +01:00
parent 5356d0d027
commit a523dd210b
18 changed files with 186 additions and 322 deletions

View File

@@ -1,9 +1,9 @@
package io.xpipe.api;
import io.xpipe.beacon.*;
import io.xpipe.beacon.socket.SocketClient;
import io.xpipe.beacon.BeaconClient;
public abstract class XPipeApiConnector extends XPipeConnector {
public abstract class XPipeApiConnector extends BeaconConnector {
public void execute() {
try {
@@ -20,7 +20,7 @@ public abstract class XPipeApiConnector extends XPipeConnector {
}
}
protected abstract void handle(SocketClient sc) throws Exception;
protected abstract void handle(BeaconClient sc) throws Exception;
@Override
protected void waitForStartup() {
@@ -34,6 +34,6 @@ public abstract class XPipeApiConnector extends XPipeConnector {
@FunctionalInterface
public static interface Handler {
void handle(SocketClient sc) throws ClientException, ServerException;
void handle(BeaconClient sc) throws ClientException, ServerException;
}
}

View File

@@ -5,7 +5,7 @@ import io.xpipe.api.XPipeApiConnector;
import io.xpipe.beacon.ClientException;
import io.xpipe.beacon.ConnectorException;
import io.xpipe.beacon.ServerException;
import io.xpipe.beacon.socket.SocketClient;
import io.xpipe.beacon.BeaconClient;
import io.xpipe.beacon.exchange.ReadTableDataExchange;
import io.xpipe.beacon.exchange.ReadTableInfoExchange;
import io.xpipe.core.data.DataStructureNode;
@@ -32,7 +32,7 @@ public class DataTableImpl implements DataTable {
var ds = DataSourceId.fromString(s);
new XPipeApiConnector() {
@Override
protected void handle(SocketClient sc) throws ClientException, ServerException, ConnectorException {
protected void handle(BeaconClient sc) throws ClientException, ServerException, ConnectorException {
var req = new ReadTableInfoExchange.Request(ds);
ReadTableInfoExchange.Response res = performSimpleExchange(sc, req);
table[0] = new DataTableImpl(res.sourceId(), res.rowCount(), res.dataType());
@@ -92,7 +92,7 @@ public class DataTableImpl implements DataTable {
List<DataStructureNode> nodes = new ArrayList<>();
new XPipeApiConnector() {
@Override
protected void handle(SocketClient sc) throws ClientException, ServerException, ConnectorException {
protected void handle(BeaconClient sc) throws ClientException, ServerException, ConnectorException {
var req = new ReadTableDataExchange.Request(id, maxToRead);
performExchange(sc, req, (ReadTableDataExchange.Response res, InputStream in) -> {
TypedDataStreamReader.readStructures(in, new TypedDataStructureNodeCallback(dataType, nodes::add));
@@ -115,7 +115,7 @@ public class DataTableImpl implements DataTable {
{
new XPipeApiConnector() {
@Override
protected void handle(SocketClient sc) throws ClientException, ServerException, ConnectorException {
protected void handle(BeaconClient sc) throws ClientException, ServerException, ConnectorException {
var req = new ReadTableDataExchange.Request(id, Integer.MAX_VALUE);
performExchange(sc, req, (ReadTableDataExchange.Response res, InputStream in) -> {
input = in;