@@ -6,6 +6,7 @@ import dev.slimevr.Keybinding
66import dev.slimevr.SLIMEVR_IDENTIFIER
77import dev.slimevr.VRServer
88import dev.slimevr.bridge.Bridge
9+ import dev.slimevr.config.ConfigManager
910import dev.slimevr.desktop.firmware.DesktopSerialFlashingHandler
1011import dev.slimevr.desktop.games.vrchat.DesktopVRCConfigHandler
1112import dev.slimevr.desktop.platform.SteamVRBridge
@@ -27,6 +28,7 @@ import org.apache.commons.lang3.SystemUtils
2728import java.io.File
2829import java.io.IOException
2930import java.lang.System
31+ import java.net.DatagramSocket
3032import java.net.ServerSocket
3133import java.nio.file.Files
3234import java.nio.file.Paths
@@ -96,36 +98,38 @@ fun main(args: Array<String>) {
9698 LogManager .closeLogger()
9799 return
98100 }
101+
102+ val configDir = resolveConfig()
103+ LogManager .info(" Using config dir: $configDir " )
104+
105+ val configManager = ConfigManager (configDir)
106+ configManager.loadConfig()
107+
99108 try {
100- // This is disabled because the config can't be read at this point
101- // ServerSocket(6969).close()
109+ DatagramSocket (configManager.vrConfig.server.trackerPort).close()
102110 ServerSocket (21110 ).close()
103111 } catch (e: IOException ) {
112+ val message = " SlimeVR start-up error! A required port (${configManager.vrConfig.server.trackerPort} and 21110) is busy. " +
113+ " Make sure there is no other instance of SlimeVR Server running."
104114 LogManager
105- .severe(
106- " SlimeVR start-up error! Required ports are busy. " +
107- " Make sure there is no other instance of SlimeVR Server running." ,
108- )
115+ .severe(message)
109116 JOptionPane
110117 .showMessageDialog(
111118 null ,
112- " SlimeVR start-up error! Required ports are busy. " +
113- " Make sure there is no other instance of SlimeVR Server running." ,
119+ message,
114120 " SlimeVR: Ports are busy" ,
115121 JOptionPane .ERROR_MESSAGE ,
116122 )
117123 LogManager .closeLogger()
118124 return
119125 }
120126 try {
121- val configDir = resolveConfig()
122- LogManager .info(" Using config dir: $configDir " )
123127 val vrServer = VRServer (
124128 ::provideBridges,
125129 { _ -> DesktopSerialHandler () },
126130 { _ -> DesktopSerialFlashingHandler () },
127131 { _ -> DesktopVRCConfigHandler () },
128- configPath = configDir ,
132+ configManager = configManager ,
129133 )
130134 vrServer.start()
131135
0 commit comments