Implement new named pipe bridge and test it lightly

This commit is contained in:
Eiren Rain committed 2021-10-01 12:27:04 +03:00
1 parent ed58076c68
commit 488838752b
8 files changed
+228 -39

No files matched your search

+20 -4
View File
@@ -1,14 +1,30 @@
package dev.slimevr.bridge;
import com.sun.jna.platform.win32.Kernel32;
import com.sun.jna.platform.win32.WinNT.HANDLE;
class Pipe {
final String name;
final HANDLE pipeHandle;
PipeState state = PipeState.CREATED;
public class Pipe {
public final String name;
public final HANDLE pipeHandle;
public PipeState state = PipeState.CREATED;
public Pipe(HANDLE pipeHandle, String name) {
this.pipeHandle = pipeHandle;
this.name = name;
}
public static void safeDisconnect(Pipe pipe) {
try {
if(pipe != null && pipe.pipeHandle != null)
Kernel32.INSTANCE.DisconnectNamedPipe(pipe.pipeHandle);
} catch(Exception e) {
}
}
enum PipeState {
CREATED,
OPEN,
ERROR;
}
}