diff options
Diffstat (limited to 'OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs')
-rw-r--r-- | OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs index 847319c..a4dd36c 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs | |||
@@ -26,8 +26,122 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
30 | using System.Collections.Specialized; | ||
31 | using System.Reflection; | ||
32 | |||
33 | using log4net; | ||
29 | using Mono.Addins; | 34 | using Mono.Addins; |
30 | using Nini.Config; | 35 | using Nini.Config; |
31 | 36 | ||
37 | using OpenSim.Framework; | ||
38 | using OpenSim.Region.Framework.Interfaces; | ||
39 | using OpenSim.Region.Framework.Scenes; | ||
40 | using OpenSim.Services.Interfaces; | ||
41 | using OpenMetaverse; | ||
42 | using OpenMetaverse.StructuredData; | ||
43 | |||
32 | [assembly: Addin("SimianGrid", "1.0")] | 44 | [assembly: Addin("SimianGrid", "1.0")] |
33 | [assembly: AddinDependency("OpenSim", "0.5")] | 45 | [assembly: AddinDependency("OpenSim", "0.5")] |
46 | |||
47 | namespace OpenSim.Services.Connectors.SimianGrid | ||
48 | { | ||
49 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimianExternalCapsModule")] | ||
50 | public class SimianGrid : ISharedRegionModule | ||
51 | { | ||
52 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
53 | |||
54 | private IConfig m_config = null; | ||
55 | private bool m_enabled = true; | ||
56 | |||
57 | private String m_simianURL; | ||
58 | |||
59 | #region IRegionModule Members | ||
60 | |||
61 | public string Name | ||
62 | { | ||
63 | get { return this.GetType().Name; } | ||
64 | } | ||
65 | |||
66 | |||
67 | public void Initialise(IConfigSource config) | ||
68 | { | ||
69 | try | ||
70 | { | ||
71 | m_config = config.Configs["SimianGrid"]; | ||
72 | |||
73 | if (m_config != null) | ||
74 | { | ||
75 | m_simianURL = m_config.GetString("SimianServiceURL"); | ||
76 | if (String.IsNullOrEmpty(m_simianURL)) | ||
77 | m_log.ErrorFormat("[SimianGrid] service URL is not defined"); | ||
78 | |||
79 | InitialiseSimCap(); | ||
80 | SimulatorCapability = SimulatorCapability.Trim(); | ||
81 | m_log.WarnFormat("[SimianExternalCaps] using {0} as simulator capability",SimulatorCapability); | ||
82 | } | ||
83 | } | ||
84 | catch (Exception e) | ||
85 | { | ||
86 | m_log.ErrorFormat("[SimianExternalCaps] initialization error: {0}",e.Message); | ||
87 | return; | ||
88 | } | ||
89 | } | ||
90 | |||
91 | public void PostInitialise() { } | ||
92 | public void Close() { } | ||
93 | public void AddRegion(Scene scene) { } | ||
94 | public void RemoveRegion(Scene scene) { } | ||
95 | public void RegionLoaded(Scene scene) { } | ||
96 | |||
97 | public Type ReplaceableInterface | ||
98 | { | ||
99 | get { return null; } | ||
100 | } | ||
101 | |||
102 | ///<summary> | ||
103 | /// Try a variety of methods for finding the simian simulator capability; first check the | ||
104 | /// configuration itself, then look for a file that contains the cap, then finally look | ||
105 | /// for an environment variable that contains it. | ||
106 | ///</summary> | ||
107 | private void InitialiseSimCap() | ||
108 | { | ||
109 | if (m_config.Contains("SimulatorCapability")) | ||
110 | { | ||
111 | SimulatorCapability = m_config.GetString("SimulatorCapability"); | ||
112 | return; | ||
113 | } | ||
114 | |||
115 | if (m_config.Contains("SimulatorCapabilityFile")) | ||
116 | { | ||
117 | String filename = m_config.GetString("SimulatorCapabilityFile"); | ||
118 | if (System.IO.File.Exists(filename)) | ||
119 | { | ||
120 | SimulatorCapability = System.IO.File.ReadAllText(filename); | ||
121 | return; | ||
122 | } | ||
123 | } | ||
124 | |||
125 | if (m_config.Contains("SimulatorCapabilityVariable")) | ||
126 | { | ||
127 | String envname = m_config.GetString("SimulatorCapabilityVariable"); | ||
128 | String envvalue = System.Environment.GetEnvironmentVariable(envname); | ||
129 | if (envvalue != null) | ||
130 | { | ||
131 | SimulatorCapability = envvalue; | ||
132 | return; | ||
133 | } | ||
134 | } | ||
135 | |||
136 | m_log.WarnFormat("[SimianExternalCaps] no method specified for simulator capability"); | ||
137 | } | ||
138 | |||
139 | #endregion | ||
140 | public static String SimulatorCapability = UUID.Zero.ToString(); | ||
141 | public static OSDMap PostToService(string url, NameValueCollection data) | ||
142 | { | ||
143 | data["cap"] = SimulatorCapability; | ||
144 | return WebUtil.PostToService(url, data); | ||
145 | } | ||
146 | } | ||
147 | } | ||