aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Server/Handlers/Simulation/Utils.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Server/Handlers/Simulation/Utils.cs (renamed from OpenSim/Grid/Framework/XMPPHTTPService.cs)109
1 files changed, 51 insertions, 58 deletions
diff --git a/OpenSim/Grid/Framework/XMPPHTTPService.cs b/OpenSim/Server/Handlers/Simulation/Utils.cs
index 9d27409..ed379da 100644
--- a/OpenSim/Grid/Framework/XMPPHTTPService.cs
+++ b/OpenSim/Server/Handlers/Simulation/Utils.cs
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
@@ -26,84 +26,77 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.IO; 29using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using log4net; 31
32using OpenMetaverse; 32using OpenMetaverse;
33using OpenSim.Framework.Servers.HttpServer; 33using OpenMetaverse.StructuredData;
34
35using log4net;
34 36
35namespace OpenSim.Grid.Framework 37namespace OpenSim.Server.Handlers.Simulation
36{ 38{
37 public class XMPPHTTPStreamHandler : BaseStreamHandler 39 public class Utils
38 { 40 {
39 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 41 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
40 42
41
42 /// <summary> 43 /// <summary>
43 /// Constructor. 44 /// Extract the param from an uri.
44 /// </summary> 45 /// </summary>
45 /// <param name="assetManager"></param> 46 /// <param name="uri">Something like this: /agent/uuid/ or /agent/uuid/handle/release</param>
46 /// <param name="assetProvider"></param> 47 /// <param name="uri">uuid on uuid field</param>
47 public XMPPHTTPStreamHandler() 48 /// <param name="action">optional action</param>
48 : base("GET", "/presence") 49 public static bool GetParams(string uri, out UUID uuid, out UUID regionID, out string action)
49 { 50 {
50 m_log.Info("[REST]: In Get Request"); 51 uuid = UUID.Zero;
52 regionID = UUID.Zero;
53 action = "";
51 54
55 uri = uri.Trim(new char[] { '/' });
56 string[] parts = uri.Split('/');
57 if (parts.Length <= 1)
58 {
59 return false;
60 }
61 else
62 {
63 if (!UUID.TryParse(parts[1], out uuid))
64 return false;
65
66 if (parts.Length >= 3)
67 UUID.TryParse(parts[2], out regionID);
68 if (parts.Length >= 4)
69 action = parts[3];
70
71 return true;
72 }
52 } 73 }
53 74
54 public override byte[] Handle(string path, Stream request, 75 public static OSDMap GetOSDMap(string data)
55 OSHttpRequest httpRequest, OSHttpResponse httpResponse)
56 { 76 {
57 string param = GetParam(path); 77 OSDMap args = null;
58 byte[] result = new byte[] {};
59 try 78 try
60 { 79 {
61 string[] p = param.Split(new char[] {'/', '?', '&'}, StringSplitOptions.RemoveEmptyEntries); 80 OSD buffer;
62 81 // We should pay attention to the content-type, but let's assume we know it's Json
63 if (p.Length > 0) 82 buffer = OSDParser.DeserializeJson(data);
83 if (buffer.Type == OSDType.Map)
64 { 84 {
65 UUID assetID = UUID.Zero; 85 args = (OSDMap)buffer;
66 86 return args;
67 if (!UUID.TryParse(p[0], out assetID)) 87 }
68 { 88 else
69 m_log.InfoFormat( 89 {
70 "[REST]: GET:/presence ignoring request with malformed UUID {0}", p[0]); 90 // uh?
71 return result; 91 m_log.Debug(("[REST COMMS]: Got OSD of unexpected type " + buffer.Type.ToString()));
72 } 92 return null;
73
74 } 93 }
75 } 94 }
76 catch (Exception e) 95 catch (Exception ex)
77 { 96 {
78 m_log.Error(e.ToString()); 97 m_log.Debug("[REST COMMS]: exception on parse of REST message " + ex.Message);
98 return null;
79 } 99 }
80 return result;
81 }
82 }
83
84 public class PostXMPPStreamHandler : BaseStreamHandler
85 {
86 // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
87
88 public override byte[] Handle(string path, Stream request,
89 OSHttpRequest httpRequest, OSHttpResponse httpResponse)
90 {
91 string param = GetParam(path);
92
93 UUID assetId;
94 if (param.Length > 0)
95 UUID.TryParse(param, out assetId);
96 // byte[] txBuffer = new byte[4096];
97
98 // TODO: Read POST serialize XMPP stanzas
99
100 return new byte[] {};
101 }
102
103 public PostXMPPStreamHandler()
104 : base("POST", "/presence")
105 {
106
107 } 100 }
108 101
109 } 102 }