updated config path locator
parent
4144af2453
commit
20aa6839fe
|
|
@ -25,16 +25,16 @@ public static partial class UnityMCPBridge
|
||||||
|
|
||||||
// Add public property to expose running state
|
// Add public property to expose running state
|
||||||
public static bool IsRunning => isRunning;
|
public static bool IsRunning => isRunning;
|
||||||
|
|
||||||
// Add method to check existence of a folder
|
// Add method to check existence of a folder
|
||||||
public static bool FolderExists(string path)
|
public static bool FolderExists(string path)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(path))
|
if (string.IsNullOrEmpty(path))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (path.Equals("Assets", StringComparison.OrdinalIgnoreCase))
|
if (path.Equals("Assets", StringComparison.OrdinalIgnoreCase))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
string fullPath = Path.Combine(Application.dataPath, path.StartsWith("Assets/") ? path.Substring(7) : path);
|
string fullPath = Path.Combine(Application.dataPath, path.StartsWith("Assets/") ? path.Substring(7) : path);
|
||||||
return Directory.Exists(fullPath);
|
return Directory.Exists(fullPath);
|
||||||
}
|
}
|
||||||
|
|
@ -50,7 +50,10 @@ public static partial class UnityMCPBridge
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string configPath = Path.Combine(Application.dataPath, "MCPServer", "config.json");
|
// Get the directory of the current script
|
||||||
|
string scriptPath = Path.GetDirectoryName(typeof(UnityMCPBridge).Assembly.Location);
|
||||||
|
string configPath = Path.Combine(scriptPath, "..", "config.json");
|
||||||
|
|
||||||
if (File.Exists(configPath))
|
if (File.Exists(configPath))
|
||||||
{
|
{
|
||||||
string jsonConfig = File.ReadAllText(configPath);
|
string jsonConfig = File.ReadAllText(configPath);
|
||||||
|
|
@ -59,7 +62,7 @@ public static partial class UnityMCPBridge
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.LogError("Server config file not found!");
|
Debug.LogError($"Server config file not found at: {configPath}");
|
||||||
serverConfig = new DefaultServerConfig();
|
serverConfig = new DefaultServerConfig();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -99,10 +102,10 @@ public static partial class UnityMCPBridge
|
||||||
var client = await listener.AcceptTcpClientAsync();
|
var client = await listener.AcceptTcpClientAsync();
|
||||||
// Enable basic socket keepalive
|
// Enable basic socket keepalive
|
||||||
client.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true);
|
client.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true);
|
||||||
|
|
||||||
// Set longer receive timeout to prevent quick disconnections
|
// Set longer receive timeout to prevent quick disconnections
|
||||||
client.ReceiveTimeout = 60000; // 60 seconds
|
client.ReceiveTimeout = 60000; // 60 seconds
|
||||||
|
|
||||||
// Fire and forget each client connection
|
// Fire and forget each client connection
|
||||||
_ = HandleClientAsync(client);
|
_ = HandleClientAsync(client);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue