/// </summary>\r
public string UserDir { get { return userDir; } }\r
\r
- private string clientDir;\r
/// <summary>\r
/// Grid client's user dir for settings and logs\r
/// </summary>\r
- public string ClientDir { get { return clientDir; } }\r
+ public string ClientDir\r
+ {\r
+ get\r
+ {\r
+ if (client != null && client.Self != null && !string.IsNullOrEmpty(client.Self.Name))\r
+ {\r
+ return Path.Combine(userDir, client.Self.Name);\r
+ }\r
+ else\r
+ {\r
+ return Environment.CurrentDirectory;\r
+ }\r
+ }\r
+ }\r
\r
public string InventoryCacheFileName { get { return Path.Combine(ClientDir, "inventory.cache"); } }\r
\r
client.Groups.OnGroupDropped += new GroupManager.GroupDroppedCallback(Groups_OnGroupDropped);\r
client.Groups.OnGroupJoined += new GroupManager.GroupJoinedCallback(Groups_OnGroupJoined);\r
client.Avatars.OnAvatarNames += new AvatarManager.AvatarNamesCallback(Avatars_OnAvatarNames);\r
- client.Network.OnLogin += new NetworkManager.LoginCallback(Network_OnLogin);\r
- client.Network.OnDisconnected += new NetworkManager.DisconnectedCallback(Network_OnDisconnected);\r
}\r
\r
public void CleanUp()\r
client.Groups.OnGroupDropped -= new GroupManager.GroupDroppedCallback(Groups_OnGroupDropped);\r
client.Groups.OnGroupJoined -= new GroupManager.GroupJoinedCallback(Groups_OnGroupJoined);\r
client.Avatars.OnAvatarNames -= new AvatarManager.AvatarNamesCallback(Avatars_OnAvatarNames);\r
- client.Network.OnLogin -= new NetworkManager.LoginCallback(Network_OnLogin);\r
- client.Network.OnDisconnected -= new NetworkManager.DisconnectedCallback(Network_OnDisconnected);\r
}\r
\r
if (MonoRuntime)\r
client.Groups.RequestCurrentGroups();\r
}\r
\r
- void Network_OnDisconnected(NetworkManager.DisconnectType reason, string message)\r
- {\r
- clientDir = null;\r
- }\r
-\r
- void Network_OnLogin(LoginStatus login, string message)\r
- {\r
- if (login != LoginStatus.Success)\r
- return;\r
-\r
- clientDir = Path.Combine(userDir, client.Self.Name);\r
- try\r
- {\r
- if (!Directory.Exists(clientDir))\r
- {\r
- Directory.CreateDirectory(clientDir);\r
- }\r
- }\r
- catch (Exception)\r
- {\r
- clientDir = Directory.GetCurrentDirectory();\r
- }\r
-\r
- }\r
-\r
public void LogClientMessage(string fileName, string message)\r
{\r
- if (clientDir == null) return;\r
-\r
lock (this)\r
{\r
try\r
fileName = fileName.Replace(lDisallowed.ToString(), "_");\r
}\r
\r
- StreamWriter logfile = File.AppendText(Path.Combine(clientDir, fileName));\r
+ StreamWriter logfile = File.AppendText(Path.Combine(ClientDir, fileName));\r
logfile.WriteLine(DateTime.Now.ToString("yyyy-MM-dd [HH:mm:ss] ") + message);\r
logfile.Close();\r
logfile.Dispose();\r