Add device event sender

Create a separate component to send device events, managed by the
controller.
This commit is contained in:
Romain Vimont
2019-05-30 22:46:52 +02:00
parent 6112095e75
commit 3149e2cf4a
5 changed files with 103 additions and 6 deletions
@@ -8,6 +8,7 @@ import java.io.Closeable;
import java.io.FileDescriptor;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
public final class DesktopConnection implements Closeable {
@@ -21,14 +22,16 @@ public final class DesktopConnection implements Closeable {
private final LocalSocket controlSocket;
private final InputStream controlInputStream;
private final OutputStream controlOutputStream;
private final ControlEventReader reader = new ControlEventReader();
private final DeviceEventWriter writer = new DeviceEventWriter();
private DesktopConnection(LocalSocket videoSocket, LocalSocket controlSocket) throws IOException {
this.videoSocket = videoSocket;
this.controlSocket = controlSocket;
controlInputStream = controlSocket.getInputStream();
controlOutputStream = controlSocket.getOutputStream();
videoFd = videoSocket.getFileDescriptor();
}
@@ -109,4 +112,8 @@ public final class DesktopConnection implements Closeable {
}
return event;
}
public void sendDeviceEvent(DeviceEvent event) throws IOException {
writer.writeTo(event, controlOutputStream);
}
}