diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Capabilities/Caps.cs | 98 |
1 files changed, 90 insertions, 8 deletions
diff --git a/OpenSim/Capabilities/Caps.cs b/OpenSim/Capabilities/Caps.cs index 241fef3..b35e6b4 100644 --- a/OpenSim/Capabilities/Caps.cs +++ b/OpenSim/Capabilities/Caps.cs | |||
@@ -64,7 +64,11 @@ namespace OpenSim.Framework.Capabilities | |||
64 | public string CapsObjectPath { get { return m_capsObjectPath; } } | 64 | public string CapsObjectPath { get { return m_capsObjectPath; } } |
65 | 65 | ||
66 | private CapsHandlers m_capsHandlers; | 66 | private CapsHandlers m_capsHandlers; |
67 | private Dictionary<string, string> m_externalCapsHandlers; | 67 | |
68 | private Dictionary<string, PollServiceEventArgs> m_pollServiceHandlers | ||
69 | = new Dictionary<string, PollServiceEventArgs>(); | ||
70 | |||
71 | private Dictionary<string, string> m_externalCapsHandlers = new Dictionary<string, string>(); | ||
68 | 72 | ||
69 | private IHttpServer m_httpListener; | 73 | private IHttpServer m_httpListener; |
70 | private UUID m_agentID; | 74 | private UUID m_agentID; |
@@ -134,8 +138,8 @@ namespace OpenSim.Framework.Capabilities | |||
134 | 138 | ||
135 | m_agentID = agent; | 139 | m_agentID = agent; |
136 | m_capsHandlers = new CapsHandlers(httpServer, httpListen, httpPort, (httpServer == null) ? false : httpServer.UseSSL); | 140 | m_capsHandlers = new CapsHandlers(httpServer, httpListen, httpPort, (httpServer == null) ? false : httpServer.UseSSL); |
137 | m_externalCapsHandlers = new Dictionary<string, string>(); | ||
138 | m_regionName = regionName; | 141 | m_regionName = regionName; |
142 | m_capsActive.Reset(); | ||
139 | } | 143 | } |
140 | 144 | ||
141 | /// <summary> | 145 | /// <summary> |
@@ -145,8 +149,29 @@ namespace OpenSim.Framework.Capabilities | |||
145 | /// <param name="handler"></param> | 149 | /// <param name="handler"></param> |
146 | public void RegisterHandler(string capName, IRequestHandler handler) | 150 | public void RegisterHandler(string capName, IRequestHandler handler) |
147 | { | 151 | { |
148 | m_capsHandlers[capName] = handler; | ||
149 | //m_log.DebugFormat("[CAPS]: Registering handler for \"{0}\": path {1}", capName, handler.Path); | 152 | //m_log.DebugFormat("[CAPS]: Registering handler for \"{0}\": path {1}", capName, handler.Path); |
153 | m_capsHandlers[capName] = handler; | ||
154 | } | ||
155 | |||
156 | public void RegisterPollHandler(string capName, PollServiceEventArgs pollServiceHandler) | ||
157 | { | ||
158 | m_pollServiceHandlers.Add(capName, pollServiceHandler); | ||
159 | |||
160 | m_httpListener.AddPollServiceHTTPHandler(pollServiceHandler.Url, pollServiceHandler); | ||
161 | |||
162 | // uint port = (MainServer.Instance == null) ? 0 : MainServer.Instance.Port; | ||
163 | // string protocol = "http"; | ||
164 | // string hostName = m_httpListenerHostName; | ||
165 | // | ||
166 | // if (MainServer.Instance.UseSSL) | ||
167 | // { | ||
168 | // hostName = MainServer.Instance.SSLCommonName; | ||
169 | // port = MainServer.Instance.SSLPort; | ||
170 | // protocol = "https"; | ||
171 | // } | ||
172 | |||
173 | // RegisterHandler( | ||
174 | // capName, String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, pollServiceHandler.Url)); | ||
150 | } | 175 | } |
151 | 176 | ||
152 | /// <summary> | 177 | /// <summary> |
@@ -165,13 +190,70 @@ namespace OpenSim.Framework.Capabilities | |||
165 | /// </summary> | 190 | /// </summary> |
166 | public void DeregisterHandlers() | 191 | public void DeregisterHandlers() |
167 | { | 192 | { |
168 | if (m_capsHandlers != null) | 193 | foreach (string capsName in m_capsHandlers.Caps) |
194 | { | ||
195 | m_capsHandlers.Remove(capsName); | ||
196 | } | ||
197 | |||
198 | foreach (PollServiceEventArgs handler in m_pollServiceHandlers.Values) | ||
199 | { | ||
200 | m_httpListener.RemovePollServiceHTTPHandler("", handler.Url); | ||
201 | } | ||
202 | } | ||
203 | |||
204 | public bool TryGetPollHandler(string name, out PollServiceEventArgs pollHandler) | ||
205 | { | ||
206 | return m_pollServiceHandlers.TryGetValue(name, out pollHandler); | ||
207 | } | ||
208 | |||
209 | public Dictionary<string, PollServiceEventArgs> GetPollHandlers() | ||
210 | { | ||
211 | return new Dictionary<string, PollServiceEventArgs>(m_pollServiceHandlers); | ||
212 | } | ||
213 | |||
214 | /// <summary> | ||
215 | /// Return an LLSD-serializable Hashtable describing the | ||
216 | /// capabilities and their handler details. | ||
217 | /// </summary> | ||
218 | /// <param name="excludeSeed">If true, then exclude the seed cap.</param> | ||
219 | public Hashtable GetCapsDetails(bool excludeSeed, List<string> requestedCaps) | ||
220 | { | ||
221 | Hashtable caps = CapsHandlers.GetCapsDetails(excludeSeed, requestedCaps); | ||
222 | |||
223 | lock (m_pollServiceHandlers) | ||
169 | { | 224 | { |
170 | foreach (string capsName in m_capsHandlers.Caps) | 225 | foreach (KeyValuePair <string, PollServiceEventArgs> kvp in m_pollServiceHandlers) |
171 | { | 226 | { |
172 | m_capsHandlers.Remove(capsName); | 227 | if (!requestedCaps.Contains(kvp.Key)) |
228 | continue; | ||
229 | |||
230 | string hostName = m_httpListenerHostName; | ||
231 | uint port = (MainServer.Instance == null) ? 0 : MainServer.Instance.Port; | ||
232 | string protocol = "http"; | ||
233 | |||
234 | if (MainServer.Instance.UseSSL) | ||
235 | { | ||
236 | hostName = MainServer.Instance.SSLCommonName; | ||
237 | port = MainServer.Instance.SSLPort; | ||
238 | protocol = "https"; | ||
239 | } | ||
240 | // | ||
241 | // caps.RegisterHandler("FetchInventoryDescendents2", String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, capUrl)); | ||
242 | |||
243 | caps[kvp.Key] = string.Format("{0}://{1}:{2}{3}", protocol, hostName, port, kvp.Value.Url); | ||
173 | } | 244 | } |
174 | } | 245 | } |
246 | |||
247 | // Add the external too | ||
248 | foreach (KeyValuePair<string, string> kvp in ExternalCapsHandlers) | ||
249 | { | ||
250 | if (!requestedCaps.Contains(kvp.Key)) | ||
251 | continue; | ||
252 | |||
253 | caps[kvp.Key] = kvp.Value; | ||
254 | } | ||
255 | |||
256 | return caps; | ||
175 | } | 257 | } |
176 | 258 | ||
177 | public void Activate() | 259 | public void Activate() |
@@ -182,7 +264,7 @@ namespace OpenSim.Framework.Capabilities | |||
182 | public bool WaitForActivation() | 264 | public bool WaitForActivation() |
183 | { | 265 | { |
184 | // Wait for 30s. If that elapses, return false and run without caps | 266 | // Wait for 30s. If that elapses, return false and run without caps |
185 | return m_capsActive.WaitOne(30000); | 267 | return m_capsActive.WaitOne(120000); |
186 | } | 268 | } |
187 | } | 269 | } |
188 | } | 270 | } \ No newline at end of file |