aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/IScene.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs10
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneBase.cs11
-rw-r--r--OpenSim/Server/Handlers/Simulation/AgentHandlers.cs244
-rw-r--r--OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs191
-rw-r--r--OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs19
-rw-r--r--OpenSim/Server/Handlers/Simulation/Utils.cs103
-rw-r--r--OpenSim/Services/Interfaces/ISimulationService.cs10
8 files changed, 572 insertions, 20 deletions
diff --git a/OpenSim/Framework/IScene.cs b/OpenSim/Framework/IScene.cs
index 8067052..27b3d47 100644
--- a/OpenSim/Framework/IScene.cs
+++ b/OpenSim/Framework/IScene.cs
@@ -66,6 +66,8 @@ namespace OpenSim.Framework
66 66
67 float TimeDilation { get; } 67 float TimeDilation { get; }
68 68
69 bool AllowScriptCrossings { get; }
70
69 event restart OnRestart; 71 event restart OnRestart;
70 72
71 void AddNewClient(IClientAPI client); 73 void AddNewClient(IClientAPI client);
@@ -96,5 +98,7 @@ namespace OpenSim.Framework
96 void StackModuleInterface<M>(M mod); 98 void StackModuleInterface<M>(M mod);
97 99
98 void AddCommand(object module, string command, string shorthelp, string longhelp, CommandDelegate callback); 100 void AddCommand(object module, string command, string shorthelp, string longhelp, CommandDelegate callback);
101
102 ISceneObject DeserializeObject(string representation);
99 } 103 }
100} 104}
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 0e1e2be..7db99e1 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -4889,5 +4889,15 @@ namespace OpenSim.Region.Framework.Scenes
4889 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) 4889 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000)
4890 StartTimer(); 4890 StartTimer();
4891 } 4891 }
4892
4893 public override ISceneObject DeserializeObject(string representation)
4894 {
4895 return SceneObjectSerializer.FromXml2Format(representation);
4896 }
4897
4898 public override bool AllowScriptCrossings
4899 {
4900 get { return m_allowScriptCrossings; }
4901 }
4892 } 4902 }
4893} 4903}
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs
index 1547f9a..19eea1e 100644
--- a/OpenSim/Region/Framework/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs
@@ -510,5 +510,16 @@ namespace OpenSim.Region.Framework.Scenes
510 510
511 MainConsole.Instance.Commands.AddCommand(modulename, shared, command, shorthelp, longhelp, callback); 511 MainConsole.Instance.Commands.AddCommand(modulename, shared, command, shorthelp, longhelp, callback);
512 } 512 }
513
514 public virtual ISceneObject DeserializeObject(string representation)
515 {
516 return null;
517 }
518
519 public virtual bool AllowScriptCrossings
520 {
521 get { return false; }
522 }
523
513 } 524 }
514} 525}
diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
index 3da72c7..4966f66 100644
--- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
+++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections;
29using System.IO; 30using System.IO;
30using System.Reflection; 31using System.Reflection;
31using System.Net; 32using System.Net;
@@ -45,6 +46,247 @@ using log4net;
45 46
46namespace OpenSim.Server.Handlers.Simulation 47namespace OpenSim.Server.Handlers.Simulation
47{ 48{
49 public class AgentHandler
50 {
51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52 private ISimulationService m_SimulationService;
53
54 public AgentHandler(ISimulationService sim)
55 {
56 m_SimulationService = sim;
57 }
58
59 public Hashtable Handler(Hashtable request)
60 {
61 //m_log.Debug("[CONNECTION DEBUGGING]: AgentHandler Called");
62
63 m_log.Debug("---------------------------");
64 m_log.Debug(" >> uri=" + request["uri"]);
65 m_log.Debug(" >> content-type=" + request["content-type"]);
66 m_log.Debug(" >> http-method=" + request["http-method"]);
67 m_log.Debug("---------------------------\n");
68
69 Hashtable responsedata = new Hashtable();
70 responsedata["content_type"] = "text/html";
71 responsedata["keepalive"] = false;
72
73
74 UUID agentID;
75 string action;
76 ulong regionHandle;
77 if (!Utils.GetParams((string)request["uri"], out agentID, out regionHandle, out action))
78 {
79 m_log.InfoFormat("[AGENT HANDLER]: Invalid parameters for agent message {0}", request["uri"]);
80 responsedata["int_response_code"] = 404;
81 responsedata["str_response_string"] = "false";
82
83 return responsedata;
84 }
85
86 // Next, let's parse the verb
87 string method = (string)request["http-method"];
88 if (method.Equals("PUT"))
89 {
90 DoAgentPut(request, responsedata);
91 return responsedata;
92 }
93 else if (method.Equals("POST"))
94 {
95 DoAgentPost(request, responsedata, agentID);
96 return responsedata;
97 }
98 else if (method.Equals("GET"))
99 {
100 DoAgentGet(request, responsedata, agentID, regionHandle);
101 return responsedata;
102 }
103 else if (method.Equals("DELETE"))
104 {
105 DoAgentDelete(request, responsedata, agentID, action, regionHandle);
106 return responsedata;
107 }
108 else
109 {
110 m_log.InfoFormat("[AGENT HANDLER]: method {0} not supported in agent message", method);
111 responsedata["int_response_code"] = HttpStatusCode.MethodNotAllowed;
112 responsedata["str_response_string"] = "Method not allowed";
113
114 return responsedata;
115 }
116
117 }
118
119 protected virtual void DoAgentPost(Hashtable request, Hashtable responsedata, UUID id)
120 {
121 OSDMap args = Utils.GetOSDMap((string)request["body"]);
122 if (args == null)
123 {
124 responsedata["int_response_code"] = HttpStatusCode.BadRequest;
125 responsedata["str_response_string"] = "Bad request";
126 return;
127 }
128
129 // retrieve the regionhandle
130 ulong regionhandle = 0;
131 if (args["destination_handle"] != null)
132 UInt64.TryParse(args["destination_handle"].AsString(), out regionhandle);
133
134 AgentCircuitData aCircuit = new AgentCircuitData();
135 try
136 {
137 aCircuit.UnpackAgentCircuitData(args);
138 }
139 catch (Exception ex)
140 {
141 m_log.InfoFormat("[AGENT HANDLER]: exception on unpacking ChildCreate message {0}", ex.Message);
142 responsedata["int_response_code"] = HttpStatusCode.BadRequest;
143 responsedata["str_response_string"] = "Bad request";
144 return;
145 }
146
147 OSDMap resp = new OSDMap(2);
148 string reason = String.Empty;
149 uint teleportFlags = 0;
150 if (args.ContainsKey("teleport_flags"))
151 {
152 teleportFlags = args["teleport_flags"].AsUInteger();
153 }
154
155 // This is the meaning of POST agent
156 //m_regionClient.AdjustUserInformation(aCircuit);
157 bool result = m_SimulationService.CreateAgent(regionhandle, aCircuit, teleportFlags, out reason);
158
159 resp["reason"] = OSD.FromString(reason);
160 resp["success"] = OSD.FromBoolean(result);
161
162 // TODO: add reason if not String.Empty?
163 responsedata["int_response_code"] = HttpStatusCode.OK;
164 responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp);
165 }
166
167 protected virtual void DoAgentPut(Hashtable request, Hashtable responsedata)
168 {
169 OSDMap args = Utils.GetOSDMap((string)request["body"]);
170 if (args == null)
171 {
172 responsedata["int_response_code"] = HttpStatusCode.BadRequest;
173 responsedata["str_response_string"] = "Bad request";
174 return;
175 }
176
177 // retrieve the regionhandle
178 ulong regionhandle = 0;
179 if (args["destination_handle"] != null)
180 UInt64.TryParse(args["destination_handle"].AsString(), out regionhandle);
181
182 string messageType;
183 if (args["message_type"] != null)
184 messageType = args["message_type"].AsString();
185 else
186 {
187 m_log.Warn("[AGENT HANDLER]: Agent Put Message Type not found. ");
188 messageType = "AgentData";
189 }
190
191 bool result = true;
192 if ("AgentData".Equals(messageType))
193 {
194 AgentData agent = new AgentData();
195 try
196 {
197 agent.Unpack(args);
198 }
199 catch (Exception ex)
200 {
201 m_log.InfoFormat("[AGENT HANDLER]: exception on unpacking ChildAgentUpdate message {0}", ex.Message);
202 responsedata["int_response_code"] = HttpStatusCode.BadRequest;
203 responsedata["str_response_string"] = "Bad request";
204 return;
205 }
206
207 //agent.Dump();
208 // This is one of the meanings of PUT agent
209 result = m_SimulationService.UpdateAgent(regionhandle, agent);
210
211 }
212 else if ("AgentPosition".Equals(messageType))
213 {
214 AgentPosition agent = new AgentPosition();
215 try
216 {
217 agent.Unpack(args);
218 }
219 catch (Exception ex)
220 {
221 m_log.InfoFormat("[AGENT HANDLER]: exception on unpacking ChildAgentUpdate message {0}", ex.Message);
222 return;
223 }
224 //agent.Dump();
225 // This is one of the meanings of PUT agent
226 result = m_SimulationService.UpdateAgent(regionhandle, agent);
227
228 }
229
230 responsedata["int_response_code"] = HttpStatusCode.OK;
231 responsedata["str_response_string"] = result.ToString();
232 //responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp); ??? instead
233 }
234
235 protected virtual void DoAgentGet(Hashtable request, Hashtable responsedata, UUID id, ulong regionHandle)
236 {
237 IAgentData agent = null;
238 bool result = m_SimulationService.RetrieveAgent(regionHandle, id, out agent);
239 OSDMap map = null;
240 if (result)
241 {
242 if (agent != null) // just to make sure
243 {
244 map = agent.Pack();
245 string strBuffer = "";
246 try
247 {
248 strBuffer = OSDParser.SerializeJsonString(map);
249 }
250 catch (Exception e)
251 {
252 m_log.WarnFormat("[AGENT HANDLER]: Exception thrown on serialization of DoAgentGet: {0}", e.Message);
253 responsedata["int_response_code"] = HttpStatusCode.InternalServerError;
254 // ignore. buffer will be empty, caller should check.
255 }
256
257 responsedata["content_type"] = "application/json";
258 responsedata["int_response_code"] = HttpStatusCode.OK;
259 responsedata["str_response_string"] = strBuffer;
260 }
261 else
262 {
263 responsedata["int_response_code"] = HttpStatusCode.InternalServerError;
264 responsedata["str_response_string"] = "Internal error";
265 }
266 }
267 else
268 {
269 responsedata["int_response_code"] = HttpStatusCode.NotFound;
270 responsedata["str_response_string"] = "Not Found";
271 }
272 }
273
274 protected virtual void DoAgentDelete(Hashtable request, Hashtable responsedata, UUID id, string action, ulong regionHandle)
275 {
276 //m_log.Debug(" >>> DoDelete action:" + action + "; regionHandle:" + regionHandle);
277
278 if (action.Equals("release"))
279 m_SimulationService.ReleaseAgent(regionHandle, id, "");
280 else
281 m_SimulationService.CloseAgent(regionHandle, id);
282
283 responsedata["int_response_code"] = HttpStatusCode.OK;
284 responsedata["str_response_string"] = "OpenSim agent " + id.ToString();
285
286 m_log.Debug("[AGENT HANDLER]: Agent Deleted.");
287 }
288 }
289
48 public class AgentGetHandler : BaseStreamHandler 290 public class AgentGetHandler : BaseStreamHandler
49 { 291 {
50 // TODO: unused: private ISimulationService m_SimulationService; 292 // TODO: unused: private ISimulationService m_SimulationService;
@@ -153,7 +395,7 @@ namespace OpenSim.Server.Handlers.Simulation
153 // m_regionClient.AdjustUserInformation(aCircuit); 395 // m_regionClient.AdjustUserInformation(aCircuit);
154 396
155 // Finally! 397 // Finally!
156 bool success = m_SimulationService.CreateAgent(regionhandle, aCircuit, out reason); 398 bool success = m_SimulationService.CreateAgent(regionhandle, aCircuit, /*!!!*/0, out reason);
157 399
158 OSDMap resp = new OSDMap(1); 400 OSDMap resp = new OSDMap(1);
159 401
diff --git a/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs b/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs
new file mode 100644
index 0000000..8c3af72
--- /dev/null
+++ b/OpenSim/Server/Handlers/Simulation/ObjectHandlers.cs
@@ -0,0 +1,191 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.IO;
31using System.Reflection;
32using System.Net;
33using System.Text;
34
35using OpenSim.Server.Base;
36using OpenSim.Server.Handlers.Base;
37using OpenSim.Services.Interfaces;
38using OpenSim.Framework;
39using OpenSim.Framework.Servers.HttpServer;
40
41using OpenMetaverse;
42using OpenMetaverse.StructuredData;
43using Nini.Config;
44using log4net;
45
46
47namespace OpenSim.Server.Handlers.Simulation
48{
49 public class ObjectHandler
50 {
51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52 private ISimulationService m_SimulationService;
53
54 public ObjectHandler(ISimulationService sim)
55 {
56 m_SimulationService = sim;
57 }
58
59 public Hashtable Handler(Hashtable request)
60 {
61 m_log.Debug("[CONNECTION DEBUGGING]: ObjectHandler Called");
62
63 m_log.Debug("---------------------------");
64 m_log.Debug(" >> uri=" + request["uri"]);
65 m_log.Debug(" >> content-type=" + request["content-type"]);
66 m_log.Debug(" >> http-method=" + request["http-method"]);
67 m_log.Debug("---------------------------\n");
68
69 Hashtable responsedata = new Hashtable();
70 responsedata["content_type"] = "text/html";
71
72 UUID objectID;
73 string action;
74 ulong regionHandle;
75 if (!Utils.GetParams((string)request["uri"], out objectID, out regionHandle, out action))
76 {
77 m_log.InfoFormat("[REST COMMS]: Invalid parameters for object message {0}", request["uri"]);
78 responsedata["int_response_code"] = 404;
79 responsedata["str_response_string"] = "false";
80
81 return responsedata;
82 }
83
84 // Next, let's parse the verb
85 string method = (string)request["http-method"];
86 if (method.Equals("POST"))
87 {
88 DoObjectPost(request, responsedata, regionHandle);
89 return responsedata;
90 }
91 else if (method.Equals("PUT"))
92 {
93 DoObjectPut(request, responsedata, regionHandle);
94 return responsedata;
95 }
96 //else if (method.Equals("DELETE"))
97 //{
98 // DoObjectDelete(request, responsedata, agentID, action, regionHandle);
99 // return responsedata;
100 //}
101 else
102 {
103 m_log.InfoFormat("[REST COMMS]: method {0} not supported in object message", method);
104 responsedata["int_response_code"] = HttpStatusCode.MethodNotAllowed;
105 responsedata["str_response_string"] = "Mthod not allowed";
106
107 return responsedata;
108 }
109
110 }
111
112 protected virtual void DoObjectPost(Hashtable request, Hashtable responsedata, ulong regionhandle)
113 {
114 OSDMap args = Utils.GetOSDMap((string)request["body"]);
115 if (args == null)
116 {
117 responsedata["int_response_code"] = 400;
118 responsedata["str_response_string"] = "false";
119 return;
120 }
121
122 string sogXmlStr = "", extraStr = "", stateXmlStr = "";
123 if (args["sog"] != null)
124 sogXmlStr = args["sog"].AsString();
125 if (args["extra"] != null)
126 extraStr = args["extra"].AsString();
127
128 IScene s = m_SimulationService.GetScene(regionhandle);
129 ISceneObject sog = null;
130 try
131 {
132 //sog = SceneObjectSerializer.FromXml2Format(sogXmlStr);
133 sog = s.DeserializeObject(sogXmlStr);
134 sog.ExtraFromXmlString(extraStr);
135 }
136 catch (Exception ex)
137 {
138 m_log.InfoFormat("[REST COMMS]: exception on deserializing scene object {0}", ex.Message);
139 responsedata["int_response_code"] = HttpStatusCode.BadRequest;
140 responsedata["str_response_string"] = "Bad request";
141 return;
142 }
143
144 if ((args["state"] != null) && s.AllowScriptCrossings)
145 {
146 stateXmlStr = args["state"].AsString();
147 if (stateXmlStr != "")
148 {
149 try
150 {
151 sog.SetState(stateXmlStr, s);
152 }
153 catch (Exception ex)
154 {
155 m_log.InfoFormat("[REST COMMS]: exception on setting state for scene object {0}", ex.Message);
156 // ignore and continue
157 }
158 }
159 }
160 // This is the meaning of POST object
161 bool result = m_SimulationService.CreateObject(regionhandle, sog, false);
162
163 responsedata["int_response_code"] = HttpStatusCode.OK;
164 responsedata["str_response_string"] = result.ToString();
165 }
166
167 protected virtual void DoObjectPut(Hashtable request, Hashtable responsedata, ulong regionhandle)
168 {
169 OSDMap args = Utils.GetOSDMap((string)request["body"]);
170 if (args == null)
171 {
172 responsedata["int_response_code"] = 400;
173 responsedata["str_response_string"] = "false";
174 return;
175 }
176
177 UUID userID = UUID.Zero, itemID = UUID.Zero;
178 if (args["userid"] != null)
179 userID = args["userid"].AsUUID();
180 if (args["itemid"] != null)
181 itemID = args["itemid"].AsUUID();
182
183 // This is the meaning of PUT object
184 bool result = m_SimulationService.CreateObject(regionhandle, userID, itemID);
185
186 responsedata["int_response_code"] = 200;
187 responsedata["str_response_string"] = result.ToString();
188 }
189
190 }
191} \ No newline at end of file
diff --git a/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs b/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs
index fe93fa5..b2aa52f 100644
--- a/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs
+++ b/OpenSim/Server/Handlers/Simulation/SimulationServiceInConnector.cs
@@ -47,13 +47,6 @@ namespace OpenSim.Server.Handlers.Simulation
47 if (serverConfig == null) 47 if (serverConfig == null)
48 throw new Exception("No section 'SimulationService' in config file"); 48 throw new Exception("No section 'SimulationService' in config file");
49 49
50 bool authentication = serverConfig.GetBoolean("RequireAuthentication", false);
51
52 if (authentication)
53 m_AuthenticationService = scene.RequestModuleInterface<IAuthenticationService>();
54
55 bool foreignGuests = serverConfig.GetBoolean("AllowForeignGuests", false);
56
57 //string simService = serverConfig.GetString("LocalServiceModule", 50 //string simService = serverConfig.GetString("LocalServiceModule",
58 // String.Empty); 51 // String.Empty);
59 52
@@ -69,12 +62,14 @@ namespace OpenSim.Server.Handlers.Simulation
69 62
70 63
71 //System.Console.WriteLine("XXXXXXXXXXXXXXXXXXX m_AssetSetvice == null? " + ((m_AssetService == null) ? "yes" : "no")); 64 //System.Console.WriteLine("XXXXXXXXXXXXXXXXXXX m_AssetSetvice == null? " + ((m_AssetService == null) ? "yes" : "no"));
72 server.AddStreamHandler(new AgentGetHandler(m_SimulationService, m_AuthenticationService)); 65 //server.AddStreamHandler(new AgentGetHandler(m_SimulationService, m_AuthenticationService));
73 server.AddStreamHandler(new AgentPostHandler(m_SimulationService, m_AuthenticationService, foreignGuests)); 66 //server.AddStreamHandler(new AgentPostHandler(m_SimulationService, m_AuthenticationService));
74 server.AddStreamHandler(new AgentPutHandler(m_SimulationService, m_AuthenticationService)); 67 //server.AddStreamHandler(new AgentPutHandler(m_SimulationService, m_AuthenticationService));
75 server.AddStreamHandler(new AgentDeleteHandler(m_SimulationService, m_AuthenticationService)); 68 //server.AddStreamHandler(new AgentDeleteHandler(m_SimulationService, m_AuthenticationService));
69 server.AddHTTPHandler("/agent/", new AgentHandler(m_SimulationService).Handler);
70 server.AddHTTPHandler("/object/", new ObjectHandler(m_SimulationService).Handler);
71
76 //server.AddStreamHandler(new ObjectPostHandler(m_SimulationService, authentication)); 72 //server.AddStreamHandler(new ObjectPostHandler(m_SimulationService, authentication));
77 //server.AddStreamHandler(new NeighborPostHandler(m_SimulationService, authentication));
78 } 73 }
79 } 74 }
80} 75}
diff --git a/OpenSim/Server/Handlers/Simulation/Utils.cs b/OpenSim/Server/Handlers/Simulation/Utils.cs
new file mode 100644
index 0000000..1f2f851
--- /dev/null
+++ b/OpenSim/Server/Handlers/Simulation/Utils.cs
@@ -0,0 +1,103 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31
32using OpenMetaverse;
33using OpenMetaverse.StructuredData;
34
35using log4net;
36
37namespace OpenSim.Server.Handlers.Simulation
38{
39 public class Utils
40 {
41 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
42
43 /// <summary>
44 /// Extract the param from an uri.
45 /// </summary>
46 /// <param name="uri">Something like this: /agent/uuid/ or /agent/uuid/handle/release</param>
47 /// <param name="uri">uuid on uuid field</param>
48 /// <param name="action">optional action</param>
49 public static bool GetParams(string uri, out UUID uuid, out ulong regionHandle, out string action)
50 {
51 uuid = UUID.Zero;
52 action = "";
53 regionHandle = 0;
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 UInt64.TryParse(parts[2], out regionHandle);
68 if (parts.Length >= 4)
69 action = parts[3];
70
71 return true;
72 }
73 }
74
75 public static OSDMap GetOSDMap(string data)
76 {
77 OSDMap args = null;
78 try
79 {
80 OSD buffer;
81 // We should pay attention to the content-type, but let's assume we know it's Json
82 buffer = OSDParser.DeserializeJson(data);
83 if (buffer.Type == OSDType.Map)
84 {
85 args = (OSDMap)buffer;
86 return args;
87 }
88 else
89 {
90 // uh?
91 m_log.Debug(("[REST COMMS]: Got OSD of unexpected type " + buffer.Type.ToString()));
92 return null;
93 }
94 }
95 catch (Exception ex)
96 {
97 m_log.Debug("[REST COMMS]: exception on parse of REST message " + ex.Message);
98 return null;
99 }
100 }
101
102 }
103}
diff --git a/OpenSim/Services/Interfaces/ISimulationService.cs b/OpenSim/Services/Interfaces/ISimulationService.cs
index a169ab7..7ba3e66 100644
--- a/OpenSim/Services/Interfaces/ISimulationService.cs
+++ b/OpenSim/Services/Interfaces/ISimulationService.cs
@@ -33,9 +33,11 @@ namespace OpenSim.Services.Interfaces
33{ 33{
34 public interface ISimulationService 34 public interface ISimulationService
35 { 35 {
36 IScene GetScene(ulong regionHandle);
37
36 #region Agents 38 #region Agents
37 39
38 bool CreateAgent(ulong regionHandle, AgentCircuitData aCircuit, out string reason); 40 bool CreateAgent(ulong regionHandle, AgentCircuitData aCircuit, uint flags, out string reason);
39 41
40 /// <summary> 42 /// <summary>
41 /// Full child agent update. 43 /// Full child agent update.
@@ -98,11 +100,5 @@ namespace OpenSim.Services.Interfaces
98 100
99 #endregion Objects 101 #endregion Objects
100 102
101 #region Regions
102
103 bool HelloNeighbour(ulong regionHandle, RegionInfo thisRegion);
104
105 #endregion Regions
106
107 } 103 }
108} 104}