aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services
diff options
context:
space:
mode:
authorDiva Canto2010-01-03 09:35:12 -0800
committerDiva Canto2010-01-03 09:35:12 -0800
commitc268e342d19b6cc5969b1c1d94f20a3f4eb844ef (patch)
tree713af45648bd51675b087af23b0ea0df9ab0f72c /OpenSim/Services
parentApplied fix for avatar connectors similar to yesterday's fix of user account ... (diff)
downloadopensim-SC_OLD-c268e342d19b6cc5969b1c1d94f20a3f4eb844ef.zip
opensim-SC_OLD-c268e342d19b6cc5969b1c1d94f20a3f4eb844ef.tar.gz
opensim-SC_OLD-c268e342d19b6cc5969b1c1d94f20a3f4eb844ef.tar.bz2
opensim-SC_OLD-c268e342d19b6cc5969b1c1d94f20a3f4eb844ef.tar.xz
* Changed ISimulation interface to take a GridRegion as input arg instead of a regionHandle.
* Added the RemoteSimulationConnectorModule, which is the replacement for RESTComms. Scenes is not using this yet, only (standalone) Login uses these region modules for now. * Completed SimulationServiceConnector and corresponding handlers.
Diffstat (limited to 'OpenSim/Services')
-rw-r--r--OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs215
-rw-r--r--OpenSim/Services/Interfaces/ISimulationService.cs18
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginService.cs2
3 files changed, 200 insertions, 35 deletions
diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
index 6f71197..fcf07c7 100644
--- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
@@ -46,7 +46,7 @@ namespace OpenSim.Services.Connectors.Simulation
46 { 46 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 48
49 private GridRegion m_Region; 49 //private GridRegion m_Region;
50 50
51 public SimulationServiceConnector() 51 public SimulationServiceConnector()
52 { 52 {
@@ -54,7 +54,7 @@ namespace OpenSim.Services.Connectors.Simulation
54 54
55 public SimulationServiceConnector(GridRegion region) 55 public SimulationServiceConnector(GridRegion region)
56 { 56 {
57 m_Region = region; 57 //m_Region = region;
58 } 58 }
59 59
60 public IScene GetScene(ulong regionHandle) 60 public IScene GetScene(ulong regionHandle)
@@ -64,7 +64,7 @@ namespace OpenSim.Services.Connectors.Simulation
64 64
65 #region Agents 65 #region Agents
66 66
67 public bool CreateAgent(ulong regionHandle, AgentCircuitData aCircuit, uint flags, out string reason) 67 public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason)
68 { 68 {
69 reason = String.Empty; 69 reason = String.Empty;
70 70
@@ -72,11 +72,11 @@ namespace OpenSim.Services.Connectors.Simulation
72 string uri = string.Empty; 72 string uri = string.Empty;
73 try 73 try
74 { 74 {
75 uri = "http://" + m_Region.ExternalEndPoint.Address + ":" + m_Region.HttpPort + "/agent/" + aCircuit.AgentID + "/"; 75 uri = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + "/agent/" + aCircuit.AgentID + "/";
76 } 76 }
77 catch (Exception e) 77 catch (Exception e)
78 { 78 {
79 m_log.Debug("[REST COMMS]: Unable to resolve external endpoint on agent create. Reason: " + e.Message); 79 m_log.Debug("[REMOTE SIMULATION CONNECTOR]: Unable to resolve external endpoint on agent create. Reason: " + e.Message);
80 reason = e.Message; 80 reason = e.Message;
81 return false; 81 return false;
82 } 82 }
@@ -98,11 +98,13 @@ namespace OpenSim.Services.Connectors.Simulation
98 } 98 }
99 catch (Exception e) 99 catch (Exception e)
100 { 100 {
101 m_log.Debug("[REST COMMS]: PackAgentCircuitData failed with exception: " + e.Message); 101 m_log.Debug("[REMOTE SIMULATION CONNECTOR]: PackAgentCircuitData failed with exception: " + e.Message);
102 } 102 }
103 // Add the regionhandle and the name of the destination region 103 // Add the input arguments
104 args["destination_handle"] = OSD.FromString(m_Region.RegionHandle.ToString()); 104 args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString());
105 args["destination_name"] = OSD.FromString(m_Region.RegionName); 105 args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString());
106 args["destination_name"] = OSD.FromString(destination.RegionName);
107 args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
106 args["teleport_flags"] = OSD.FromString(flags.ToString()); 108 args["teleport_flags"] = OSD.FromString(flags.ToString());
107 109
108 string strBuffer = ""; 110 string strBuffer = "";
@@ -116,7 +118,7 @@ namespace OpenSim.Services.Connectors.Simulation
116 } 118 }
117 catch (Exception e) 119 catch (Exception e)
118 { 120 {
119 m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of ChildCreate: {0}", e.Message); 121 m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR]: Exception thrown on serialization of ChildCreate: {0}", e.Message);
120 // ignore. buffer will be empty, caller should check. 122 // ignore. buffer will be empty, caller should check.
121 } 123 }
122 124
@@ -126,12 +128,12 @@ namespace OpenSim.Services.Connectors.Simulation
126 AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send 128 AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send
127 os = AgentCreateRequest.GetRequestStream(); 129 os = AgentCreateRequest.GetRequestStream();
128 os.Write(buffer, 0, strBuffer.Length); //Send it 130 os.Write(buffer, 0, strBuffer.Length); //Send it
129 //m_log.InfoFormat("[REST COMMS]: Posted CreateChildAgent request to remote sim {0}", uri); 131 //m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Posted CreateChildAgent request to remote sim {0}", uri);
130 } 132 }
131 //catch (WebException ex) 133 //catch (WebException ex)
132 catch 134 catch
133 { 135 {
134 //m_log.InfoFormat("[REST COMMS]: Bad send on ChildAgentUpdate {0}", ex.Message); 136 //m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Bad send on ChildAgentUpdate {0}", ex.Message);
135 reason = "cannot contact remote region"; 137 reason = "cannot contact remote region";
136 return false; 138 return false;
137 } 139 }
@@ -142,7 +144,7 @@ namespace OpenSim.Services.Connectors.Simulation
142 } 144 }
143 145
144 // Let's wait for the response 146 // Let's wait for the response
145 //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); 147 //m_log.Info("[REMOTE SIMULATION CONNECTOR]: Waiting for a reply after DoCreateChildAgentCall");
146 148
147 WebResponse webResponse = null; 149 WebResponse webResponse = null;
148 StreamReader sr = null; 150 StreamReader sr = null;
@@ -151,14 +153,14 @@ namespace OpenSim.Services.Connectors.Simulation
151 webResponse = AgentCreateRequest.GetResponse(); 153 webResponse = AgentCreateRequest.GetResponse();
152 if (webResponse == null) 154 if (webResponse == null)
153 { 155 {
154 m_log.Info("[REST COMMS]: Null reply on DoCreateChildAgentCall post"); 156 m_log.Info("[REMOTE SIMULATION CONNECTOR]: Null reply on DoCreateChildAgentCall post");
155 } 157 }
156 else 158 else
157 { 159 {
158 160
159 sr = new StreamReader(webResponse.GetResponseStream()); 161 sr = new StreamReader(webResponse.GetResponseStream());
160 string response = sr.ReadToEnd().Trim(); 162 string response = sr.ReadToEnd().Trim();
161 m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", response); 163 m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: DoCreateChildAgentCall reply was {0} ", response);
162 164
163 if (!String.IsNullOrEmpty(response)) 165 if (!String.IsNullOrEmpty(response))
164 { 166 {
@@ -172,7 +174,7 @@ namespace OpenSim.Services.Connectors.Simulation
172 } 174 }
173 catch (NullReferenceException e) 175 catch (NullReferenceException e)
174 { 176 {
175 m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateChildAgentCall {0}", e.Message); 177 m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", e.Message);
176 178
177 // check for old style response 179 // check for old style response
178 if (response.ToLower().StartsWith("true")) 180 if (response.ToLower().StartsWith("true"))
@@ -185,7 +187,7 @@ namespace OpenSim.Services.Connectors.Simulation
185 } 187 }
186 catch (WebException ex) 188 catch (WebException ex)
187 { 189 {
188 m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateChildAgentCall {0}", ex.Message); 190 m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", ex.Message);
189 // ignore, really 191 // ignore, really
190 } 192 }
191 finally 193 finally
@@ -197,28 +199,189 @@ namespace OpenSim.Services.Connectors.Simulation
197 return true; 199 return true;
198 } 200 }
199 201
200 public bool UpdateAgent(ulong regionHandle, AgentData data) 202 public bool UpdateAgent(GridRegion destination, AgentData data)
201 { 203 {
202 return false; 204 return UpdateAgent(destination, data);
203 } 205 }
204 206
205 public bool UpdateAgent(ulong regionHandle, AgentPosition data) 207 public bool UpdateAgent(GridRegion destination, AgentPosition data)
206 { 208 {
207 return false; 209 return UpdateAgent(destination, data);
208 } 210 }
209 211
210 public bool RetrieveAgent(ulong regionHandle, UUID id, out IAgentData agent) 212 private bool UpdateAgent(GridRegion destination, IAgentData cAgentData)
213 {
214 // Eventually, we want to use a caps url instead of the agentID
215 string uri = string.Empty;
216 try
217 {
218 uri = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + "/agent/" + cAgentData.AgentID + "/";
219 }
220 catch (Exception e)
221 {
222 m_log.Debug("[REMOTE SIMULATION CONNECTOR]: Unable to resolve external endpoint on agent update. Reason: " + e.Message);
223 return false;
224 }
225 //Console.WriteLine(" >>> DoChildAgentUpdateCall <<< " + uri);
226
227 HttpWebRequest ChildUpdateRequest = (HttpWebRequest)WebRequest.Create(uri);
228 ChildUpdateRequest.Method = "PUT";
229 ChildUpdateRequest.ContentType = "application/json";
230 ChildUpdateRequest.Timeout = 10000;
231 //ChildUpdateRequest.KeepAlive = false;
232
233 // Fill it in
234 OSDMap args = null;
235 try
236 {
237 args = cAgentData.Pack();
238 }
239 catch (Exception e)
240 {
241 m_log.Debug("[REMOTE SIMULATION CONNECTOR]: PackUpdateMessage failed with exception: " + e.Message);
242 }
243 // Add the input arguments
244 args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString());
245 args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString());
246 args["destination_name"] = OSD.FromString(destination.RegionName);
247 args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
248
249 string strBuffer = "";
250 byte[] buffer = new byte[1];
251 try
252 {
253 strBuffer = OSDParser.SerializeJsonString(args);
254 Encoding str = Util.UTF8;
255 buffer = str.GetBytes(strBuffer);
256
257 }
258 catch (Exception e)
259 {
260 m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR]: Exception thrown on serialization of ChildUpdate: {0}", e.Message);
261 // ignore. buffer will be empty, caller should check.
262 }
263
264 Stream os = null;
265 try
266 { // send the Post
267 ChildUpdateRequest.ContentLength = buffer.Length; //Count bytes to send
268 os = ChildUpdateRequest.GetRequestStream();
269 os.Write(buffer, 0, strBuffer.Length); //Send it
270 //m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Posted ChildAgentUpdate request to remote sim {0}", uri);
271 }
272 //catch (WebException ex)
273 catch
274 {
275 //m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Bad send on ChildAgentUpdate {0}", ex.Message);
276
277 return false;
278 }
279 finally
280 {
281 if (os != null)
282 os.Close();
283 }
284
285 // Let's wait for the response
286 //m_log.Info("[REMOTE SIMULATION CONNECTOR]: Waiting for a reply after ChildAgentUpdate");
287
288 WebResponse webResponse = null;
289 StreamReader sr = null;
290 try
291 {
292 webResponse = ChildUpdateRequest.GetResponse();
293 if (webResponse == null)
294 {
295 m_log.Info("[REMOTE SIMULATION CONNECTOR]: Null reply on ChilAgentUpdate post");
296 }
297
298 sr = new StreamReader(webResponse.GetResponseStream());
299 //reply = sr.ReadToEnd().Trim();
300 sr.ReadToEnd().Trim();
301 sr.Close();
302 //m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: ChilAgentUpdate reply was {0} ", reply);
303
304 }
305 catch (WebException ex)
306 {
307 m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of ChilAgentUpdate {0}", ex.Message);
308 // ignore, really
309 }
310 finally
311 {
312 if (sr != null)
313 sr.Close();
314 }
315
316 return true;
317 }
318
319 public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent)
211 { 320 {
212 agent = null; 321 agent = null;
322 // Eventually, we want to use a caps url instead of the agentID
323 string uri = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + "/agent/" + id + "/" + destination.RegionID.ToString() + "/";
324 //Console.WriteLine(" >>> DoRetrieveRootAgentCall <<< " + uri);
325
326 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
327 request.Method = "GET";
328 request.Timeout = 10000;
329 //request.Headers.Add("authorization", ""); // coming soon
330
331 HttpWebResponse webResponse = null;
332 string reply = string.Empty;
333 StreamReader sr = null;
334 try
335 {
336 webResponse = (HttpWebResponse)request.GetResponse();
337 if (webResponse == null)
338 {
339 m_log.Info("[REMOTE SIMULATION CONNECTOR]: Null reply on agent get ");
340 }
341
342 sr = new StreamReader(webResponse.GetResponseStream());
343 reply = sr.ReadToEnd().Trim();
344
345 //Console.WriteLine("[REMOTE SIMULATION CONNECTOR]: ChilAgentUpdate reply was " + reply);
346
347 }
348 catch (WebException ex)
349 {
350 m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of agent get {0}", ex.Message);
351 // ignore, really
352 return false;
353 }
354 finally
355 {
356 if (sr != null)
357 sr.Close();
358 }
359
360 if (webResponse.StatusCode == HttpStatusCode.OK)
361 {
362 // we know it's jason
363 OSDMap args = Util.GetOSDMap(reply);
364 if (args == null)
365 {
366 //Console.WriteLine("[REMOTE SIMULATION CONNECTOR]: Error getting OSDMap from reply");
367 return false;
368 }
369
370 agent = new CompleteAgentData();
371 agent.Unpack(args);
372 return true;
373 }
374
375 //Console.WriteLine("[REMOTE SIMULATION CONNECTOR]: DoRetrieveRootAgentCall returned status " + webResponse.StatusCode);
213 return false; 376 return false;
214 } 377 }
215 378
216 public bool ReleaseAgent(ulong regionHandle, UUID id, string uri) 379 public bool ReleaseAgent(GridRegion destination, UUID id, string uri)
217 { 380 {
218 return false; 381 return false;
219 } 382 }
220 383
221 public bool CloseAgent(ulong regionHandle, UUID id) 384 public bool CloseAgent(GridRegion destination, UUID id)
222 { 385 {
223 return false; 386 return false;
224 } 387 }
@@ -227,12 +390,12 @@ namespace OpenSim.Services.Connectors.Simulation
227 390
228 #region Objects 391 #region Objects
229 392
230 public bool CreateObject(ulong regionHandle, ISceneObject sog, bool isLocalCall) 393 public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall)
231 { 394 {
232 return false; 395 return false;
233 } 396 }
234 397
235 public bool CreateObject(ulong regionHandle, UUID userID, UUID itemID) 398 public bool CreateObject(GridRegion destination, UUID userID, UUID itemID)
236 { 399 {
237 return false; 400 return false;
238 } 401 }
diff --git a/OpenSim/Services/Interfaces/ISimulationService.cs b/OpenSim/Services/Interfaces/ISimulationService.cs
index 7ba3e66..14f462c 100644
--- a/OpenSim/Services/Interfaces/ISimulationService.cs
+++ b/OpenSim/Services/Interfaces/ISimulationService.cs
@@ -29,6 +29,8 @@ using System;
29using OpenSim.Framework; 29using OpenSim.Framework;
30using OpenMetaverse; 30using OpenMetaverse;
31 31
32using GridRegion = OpenSim.Services.Interfaces.GridRegion;
33
32namespace OpenSim.Services.Interfaces 34namespace OpenSim.Services.Interfaces
33{ 35{
34 public interface ISimulationService 36 public interface ISimulationService
@@ -37,7 +39,7 @@ namespace OpenSim.Services.Interfaces
37 39
38 #region Agents 40 #region Agents
39 41
40 bool CreateAgent(ulong regionHandle, AgentCircuitData aCircuit, uint flags, out string reason); 42 bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason);
41 43
42 /// <summary> 44 /// <summary>
43 /// Full child agent update. 45 /// Full child agent update.
@@ -45,7 +47,7 @@ namespace OpenSim.Services.Interfaces
45 /// <param name="regionHandle"></param> 47 /// <param name="regionHandle"></param>
46 /// <param name="data"></param> 48 /// <param name="data"></param>
47 /// <returns></returns> 49 /// <returns></returns>
48 bool UpdateAgent(ulong regionHandle, AgentData data); 50 bool UpdateAgent(GridRegion destination, AgentData data);
49 51
50 /// <summary> 52 /// <summary>
51 /// Short child agent update, mostly for position. 53 /// Short child agent update, mostly for position.
@@ -53,9 +55,9 @@ namespace OpenSim.Services.Interfaces
53 /// <param name="regionHandle"></param> 55 /// <param name="regionHandle"></param>
54 /// <param name="data"></param> 56 /// <param name="data"></param>
55 /// <returns></returns> 57 /// <returns></returns>
56 bool UpdateAgent(ulong regionHandle, AgentPosition data); 58 bool UpdateAgent(GridRegion destination, AgentPosition data);
57 59
58 bool RetrieveAgent(ulong regionHandle, UUID id, out IAgentData agent); 60 bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent);
59 61
60 /// <summary> 62 /// <summary>
61 /// Message from receiving region to departing region, telling it got contacted by the client. 63 /// Message from receiving region to departing region, telling it got contacted by the client.
@@ -65,7 +67,7 @@ namespace OpenSim.Services.Interfaces
65 /// <param name="id"></param> 67 /// <param name="id"></param>
66 /// <param name="uri"></param> 68 /// <param name="uri"></param>
67 /// <returns></returns> 69 /// <returns></returns>
68 bool ReleaseAgent(ulong regionHandle, UUID id, string uri); 70 bool ReleaseAgent(GridRegion destination, UUID id, string uri);
69 71
70 /// <summary> 72 /// <summary>
71 /// Close agent. 73 /// Close agent.
@@ -73,7 +75,7 @@ namespace OpenSim.Services.Interfaces
73 /// <param name="regionHandle"></param> 75 /// <param name="regionHandle"></param>
74 /// <param name="id"></param> 76 /// <param name="id"></param>
75 /// <returns></returns> 77 /// <returns></returns>
76 bool CloseAgent(ulong regionHandle, UUID id); 78 bool CloseAgent(GridRegion destination, UUID id);
77 79
78 #endregion Agents 80 #endregion Agents
79 81
@@ -86,7 +88,7 @@ namespace OpenSim.Services.Interfaces
86 /// <param name="sog"></param> 88 /// <param name="sog"></param>
87 /// <param name="isLocalCall"></param> 89 /// <param name="isLocalCall"></param>
88 /// <returns></returns> 90 /// <returns></returns>
89 bool CreateObject(ulong regionHandle, ISceneObject sog, bool isLocalCall); 91 bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall);
90 92
91 /// <summary> 93 /// <summary>
92 /// Create an object from the user's inventory in the destination region. 94 /// Create an object from the user's inventory in the destination region.
@@ -96,7 +98,7 @@ namespace OpenSim.Services.Interfaces
96 /// <param name="userID"></param> 98 /// <param name="userID"></param>
97 /// <param name="itemID"></param> 99 /// <param name="itemID"></param>
98 /// <returns></returns> 100 /// <returns></returns>
99 bool CreateObject(ulong regionHandle, UUID userID, UUID itemID); 101 bool CreateObject(GridRegion destination, UUID userID, UUID itemID);
100 102
101 #endregion Objects 103 #endregion Objects
102 104
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs
index 82e5ba4..638fa9f 100644
--- a/OpenSim/Services/LLLoginService/LLLoginService.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginService.cs
@@ -370,7 +370,7 @@ namespace OpenSim.Services.LLLoginService
370 aCircuit.SessionID = session; 370 aCircuit.SessionID = session;
371 aCircuit.startpos = position; 371 aCircuit.startpos = position;
372 372
373 if (simConnector.CreateAgent(region.RegionHandle, aCircuit, 0, out reason)) 373 if (simConnector.CreateAgent(region, aCircuit, 0, out reason))
374 return aCircuit; 374 return aCircuit;
375 375
376 return null; 376 return null;