aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/DataSnapshot/DataRequestHandler.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/DataSnapshot/DataRequestHandler.cs37
1 files changed, 37 insertions, 0 deletions
diff --git a/OpenSim/Region/DataSnapshot/DataRequestHandler.cs b/OpenSim/Region/DataSnapshot/DataRequestHandler.cs
index e08934b..abf2c1a 100644
--- a/OpenSim/Region/DataSnapshot/DataRequestHandler.cs
+++ b/OpenSim/Region/DataSnapshot/DataRequestHandler.cs
@@ -26,11 +26,16 @@
26* 26*
27*/ 27*/
28 28
29using System;
29using System.Collections; 30using System.Collections;
30using System.Reflection; 31using System.Reflection;
31using System.Xml; 32using System.Xml;
32using log4net; 33using log4net;
33using OpenSim.Region.Environment.Scenes; 34using OpenSim.Region.Environment.Scenes;
35using OpenSim.Framework.Communications.Capabilities;
36using Caps = OpenSim.Framework.Communications.Capabilities.Caps;
37using libsecondlife;
38using OpenSim.Framework.Servers;
34 39
35namespace OpenSim.Region.DataSnapshot 40namespace OpenSim.Region.DataSnapshot
36{ 41{
@@ -40,18 +45,50 @@ namespace OpenSim.Region.DataSnapshot
40 private DataSnapshotManager m_externalData = null; 45 private DataSnapshotManager m_externalData = null;
41 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
42 47
48 private readonly string m_discoveryPath = "DS0001/";
49
43 public DataRequestHandler(Scene scene, DataSnapshotManager externalData) 50 public DataRequestHandler(Scene scene, DataSnapshotManager externalData)
44 { 51 {
45 m_scene = scene; 52 m_scene = scene;
46 m_externalData = externalData; 53 m_externalData = externalData;
47 54
55 //Register HTTP handler
48 if (m_scene.AddHTTPHandler("collector", OnGetSnapshot)) 56 if (m_scene.AddHTTPHandler("collector", OnGetSnapshot))
49 { 57 {
50 m_log.Info("[DATASNAPSHOT]: Set up snapshot service"); 58 m_log.Info("[DATASNAPSHOT]: Set up snapshot service");
51 } 59 }
60
61 //Register CAPS handler event
62 m_scene.EventManager.OnRegisterCaps += OnRegisterCaps;
63
52 //harbl 64 //harbl
53 } 65 }
54 66
67 public void OnRegisterCaps(LLUUID agentID, Caps caps)
68 {
69 m_log.Info("[DATASNAPSHOT]: Registering service discovery capability for " + agentID);
70 string capsBase = "/CAPS/" + caps.CapsObjectPath;
71 caps.RegisterHandler("PublicSnapshotDataInfo",
72 new RestStreamHandler("POST", capsBase + m_discoveryPath, OnDiscoveryAttempt));
73 }
74
75 public string OnDiscoveryAttempt(string request, string path, string param)
76 {
77 //Very static for now, flexible enough to add new formats
78 LLSDDiscoveryResponse llsd_response = new LLSDDiscoveryResponse();
79 llsd_response.snapshot_resources = new LLSDArray();
80
81 LLSDDiscoveryDataURL llsd_dataurl = new LLSDDiscoveryDataURL();
82 llsd_dataurl.snapshot_format = "os-datasnapshot-v1";
83 llsd_dataurl.snapshot_url = "http://" + m_externalData.m_hostname + ":" + m_externalData.m_listener_port + "/?method=collector";
84
85 llsd_response.snapshot_resources.Array.Add(llsd_dataurl);
86
87 string response = LLSDHelpers.SerialiseLLSDReply(llsd_response);
88
89 return response;
90 }
91
55 public Hashtable OnGetSnapshot(Hashtable keysvals) 92 public Hashtable OnGetSnapshot(Hashtable keysvals)
56 { 93 {
57 m_log.Info("[DATASNAPSHOT] Received collection request"); 94 m_log.Info("[DATASNAPSHOT] Received collection request");