Merge pull request #528 from ImUrX/linux-openvr-tmp

Use XDG_RUNTIME_DIR for socket
This commit is contained in:
Eiren Rain authored and GitHub committed 2023-01-31 20:01:41 +02:00
commit 56e451eca3
3 files changed
+12 -5

No files matched your search

@@ -32,6 +32,7 @@ import solarxr_protocol.datatypes.TrackerIdT;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.nio.file.Paths;
import java.util.List;
import java.util.Queue;
import java.util.Timer;
@@ -133,7 +134,7 @@ public class VRServer extends Thread {
hmdTracker,
"steamvr",
"SteamVR Driver Bridge",
"/tmp/SlimeVRDriver",
Paths.get(OperatingSystem.getTempDirectory(), "SlimeVRDriver").toString(),
shareTrackers
);
} catch (Exception ex) {
@@ -93,7 +93,6 @@ public class UnixSocketBridge extends SteamVRBridge implements AutoCloseable {
@Override
@BridgeThread
protected boolean sendMessageReal(ProtobufMessages.ProtobufMessage message) {
LogManager.debug("Sending msg: " + message.toString());
if (this.channel != null) {
try {
int size = message.getSerializedSize() + 4;
@@ -136,7 +135,6 @@ public class UnixSocketBridge extends SteamVRBridge implements AutoCloseable {
// dst, so we need to move position ourselves)
try {
var message = parseMessage(dst.array(), 4, messageLength - 4);
LogManager.debug("Receiving msg " + message.toString());
this.messageReceived(message);
} catch (InvalidProtocolBufferException e) {
LogManager.severe("Failed to read protocol message", e);
@@ -11,7 +11,7 @@ public enum OperatingSystem {
OSX("osx", new String[]{"mac"}),
UNKNOWN("unknown", new String[0]);
//@fomatter: on
private final String[] aliases;
public final String name;
private static OperatingSystem currentPlatform;
@@ -44,4 +44,12 @@ public enum OperatingSystem {
}
return UNKNOWN;
}
}
public static String getTempDirectory() {
if(currentPlatform == LINUX) {
String tmp = System.getenv("XDG_RUNTIME_DIR");
if(tmp != null) return tmp;
}
return System.getProperty("java.io.tmpdir");
}
}