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