Update osGetGrid**** functions

The osGetGrid**** functions will now get the grid settings from the GridInfoService. Set the GridInfoURI in your ./bin/config-include/GridCommon.ini [GridInfo] section.
iar_mods
BlueWall 2012-01-17 22:07:40 -05:00
parent 939d60da59
commit 9ed9720861
2 changed files with 75 additions and 3 deletions

View File

@ -1944,6 +1944,54 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
} }
private enum InfoType
{
Nick,
Name,
Login
};
private string GridUserInfo(InfoType type)
{
string retval = String.Empty;
IConfigSource config = m_ScriptEngine.ConfigSource;
string url = config.Configs["GridInfo"].GetString("GridInfoURI", String.Empty);
if (String.IsNullOrEmpty(url))
return "Configuration Error!";
string verb ="/json_grid_info";
OSDMap json = new OSDMap();
OSDMap info = WebUtil.GetFromService(String.Format("{0}{1}",url,verb), 3000);
if (info["Success"] != true)
return "Get GridInfo Failed!";
json = (OSDMap)OSDParser.DeserializeJson(info["_RawResult"].AsString());
switch (type)
{
case InfoType.Nick:
retval = json["gridnick"];
break;
case InfoType.Name:
retval = json["gridname"];
break;
case InfoType.Login:
retval = json["login"];
break;
default:
retval = "error";
break;
}
return retval;
}
/// <summary> /// <summary>
/// Get the nickname of this grid, as set in the [GridInfo] config section. /// Get the nickname of this grid, as set in the [GridInfo] config section.
/// </summary> /// </summary>
@ -1957,10 +2005,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
CheckThreatLevel(ThreatLevel.Moderate, "osGetGridNick"); CheckThreatLevel(ThreatLevel.Moderate, "osGetGridNick");
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
string nick = "hippogrid";
string nick = String.Empty;
IConfigSource config = m_ScriptEngine.ConfigSource; IConfigSource config = m_ScriptEngine.ConfigSource;
if (config.Configs["GridInfo"] != null) if (config.Configs["GridInfo"] != null)
nick = config.Configs["GridInfo"].GetString("gridnick", nick); nick = config.Configs["GridInfo"].GetString("gridnick", nick);
if (String.IsNullOrEmpty(nick))
nick = GridUserInfo(InfoType.Nick);
return nick; return nick;
} }
@ -1968,10 +2022,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
CheckThreatLevel(ThreatLevel.Moderate, "osGetGridName"); CheckThreatLevel(ThreatLevel.Moderate, "osGetGridName");
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
string name = "the lost continent of hippo";
string name = String.Empty;
IConfigSource config = m_ScriptEngine.ConfigSource; IConfigSource config = m_ScriptEngine.ConfigSource;
if (config.Configs["GridInfo"] != null) if (config.Configs["GridInfo"] != null)
name = config.Configs["GridInfo"].GetString("gridname", name); name = config.Configs["GridInfo"].GetString("gridname", name);
if (String.IsNullOrEmpty(name))
name = GridUserInfo(InfoType.Name);
return name; return name;
} }
@ -1979,10 +2039,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
CheckThreatLevel(ThreatLevel.Moderate, "osGetGridLoginURI"); CheckThreatLevel(ThreatLevel.Moderate, "osGetGridLoginURI");
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
string loginURI = "http://127.0.0.1:9000/";
string loginURI = String.Empty;
IConfigSource config = m_ScriptEngine.ConfigSource; IConfigSource config = m_ScriptEngine.ConfigSource;
if (config.Configs["GridInfo"] != null) if (config.Configs["GridInfo"] != null)
loginURI = config.Configs["GridInfo"].GetString("login", loginURI); loginURI = config.Configs["GridInfo"].GetString("login", loginURI);
if (String.IsNullOrEmpty(loginURI))
loginURI = GridUserInfo(InfoType.Login);
return loginURI; return loginURI;
} }

View File

@ -58,6 +58,12 @@
; ;
InventoryServerURI = "http://mygridserver.com:8003" InventoryServerURI = "http://mygridserver.com:8003"
[GridInfo]
;
; Change this to your grid info service
;
GridInfoURI = "http://mygridserver.com:8002"
[GridService] [GridService]
; ;
; Change this to your grid-wide grid server ; Change this to your grid-wide grid server