diff options
Diffstat (limited to 'OpenSim/Services/Connectors')
22 files changed, 1047 insertions, 697 deletions
diff --git a/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs index 8b702e0..bf0cc35 100644 --- a/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs +++ b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs | |||
@@ -66,6 +66,12 @@ namespace OpenSim.Services.Connectors | |||
66 | 66 | ||
67 | private Thread[] m_fetchThreads; | 67 | private Thread[] m_fetchThreads; |
68 | 68 | ||
69 | public int MaxAssetRequestConcurrency | ||
70 | { | ||
71 | get { return m_maxAssetRequestConcurrency; } | ||
72 | set { m_maxAssetRequestConcurrency = value; } | ||
73 | } | ||
74 | |||
69 | public AssetServicesConnector() | 75 | public AssetServicesConnector() |
70 | { | 76 | { |
71 | } | 77 | } |
diff --git a/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs b/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs index f982cc1..af91cdb 100644 --- a/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs +++ b/OpenSim/Services/Connectors/Grid/GridServicesConnector.cs | |||
@@ -525,6 +525,57 @@ namespace OpenSim.Services.Connectors | |||
525 | return rinfos; | 525 | return rinfos; |
526 | } | 526 | } |
527 | 527 | ||
528 | public List<GridRegion> GetDefaultHypergridRegions(UUID scopeID) | ||
529 | { | ||
530 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
531 | |||
532 | sendData["SCOPEID"] = scopeID.ToString(); | ||
533 | |||
534 | sendData["METHOD"] = "get_default_hypergrid_regions"; | ||
535 | |||
536 | List<GridRegion> rinfos = new List<GridRegion>(); | ||
537 | string reply = string.Empty; | ||
538 | string uri = m_ServerURI + "/grid"; | ||
539 | try | ||
540 | { | ||
541 | reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
542 | uri, | ||
543 | ServerUtils.BuildQueryString(sendData)); | ||
544 | |||
545 | //m_log.DebugFormat("[GRID CONNECTOR]: reply was {0}", reply); | ||
546 | } | ||
547 | catch (Exception e) | ||
548 | { | ||
549 | m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server at {0}: {1}", uri, e.Message); | ||
550 | return rinfos; | ||
551 | } | ||
552 | |||
553 | if (reply != string.Empty) | ||
554 | { | ||
555 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
556 | |||
557 | if (replyData != null) | ||
558 | { | ||
559 | Dictionary<string, object>.ValueCollection rinfosList = replyData.Values; | ||
560 | foreach (object r in rinfosList) | ||
561 | { | ||
562 | if (r is Dictionary<string, object>) | ||
563 | { | ||
564 | GridRegion rinfo = new GridRegion((Dictionary<string, object>)r); | ||
565 | rinfos.Add(rinfo); | ||
566 | } | ||
567 | } | ||
568 | } | ||
569 | else | ||
570 | m_log.DebugFormat("[GRID CONNECTOR]: GetDefaultHypergridRegions {0} received null response", | ||
571 | scopeID); | ||
572 | } | ||
573 | else | ||
574 | m_log.DebugFormat("[GRID CONNECTOR]: GetDefaultHypergridRegions received null reply"); | ||
575 | |||
576 | return rinfos; | ||
577 | } | ||
578 | |||
528 | public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y) | 579 | public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y) |
529 | { | 580 | { |
530 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | 581 | Dictionary<string, object> sendData = new Dictionary<string, object>(); |
diff --git a/OpenSim/Services/Connectors/GridUser/GridUserServicesConnector.cs b/OpenSim/Services/Connectors/GridUser/GridUserServicesConnector.cs index 94bda82..1a62d2f 100644 --- a/OpenSim/Services/Connectors/GridUser/GridUserServicesConnector.cs +++ b/OpenSim/Services/Connectors/GridUser/GridUserServicesConnector.cs | |||
@@ -214,7 +214,7 @@ namespace OpenSim.Services.Connectors | |||
214 | 214 | ||
215 | } | 215 | } |
216 | else | 216 | else |
217 | m_log.DebugFormat("[GRID USER CONNECTOR]: Loggedin received empty reply"); | 217 | m_log.DebugFormat("[GRID USER CONNECTOR]: Get received empty reply"); |
218 | } | 218 | } |
219 | catch (Exception e) | 219 | catch (Exception e) |
220 | { | 220 | { |
diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs index d840527..803cd1b 100644 --- a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs | |||
@@ -53,7 +53,8 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
53 | 53 | ||
54 | private IAssetService m_AssetService; | 54 | private IAssetService m_AssetService; |
55 | 55 | ||
56 | public GatekeeperServiceConnector() : base() | 56 | public GatekeeperServiceConnector() |
57 | : base() | ||
57 | { | 58 | { |
58 | } | 59 | } |
59 | 60 | ||
@@ -123,11 +124,13 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
123 | realHandle = Convert.ToUInt64((string)hash["handle"]); | 124 | realHandle = Convert.ToUInt64((string)hash["handle"]); |
124 | //m_log.Debug(">> HERE, realHandle: " + realHandle); | 125 | //m_log.Debug(">> HERE, realHandle: " + realHandle); |
125 | } | 126 | } |
126 | if (hash["region_image"] != null) { | 127 | if (hash["region_image"] != null) |
128 | { | ||
127 | imageURL = (string)hash["region_image"]; | 129 | imageURL = (string)hash["region_image"]; |
128 | //m_log.Debug(">> HERE, imageURL: " + imageURL); | 130 | //m_log.Debug(">> HERE, imageURL: " + imageURL); |
129 | } | 131 | } |
130 | if (hash["external_name"] != null) { | 132 | if (hash["external_name"] != null) |
133 | { | ||
131 | externalName = (string)hash["external_name"]; | 134 | externalName = (string)hash["external_name"]; |
132 | //m_log.Debug(">> HERE, externalName: " + externalName); | 135 | //m_log.Debug(">> HERE, externalName: " + externalName); |
133 | } | 136 | } |
@@ -179,7 +182,7 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
179 | //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); | 182 | //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); |
180 | imageData = OpenJPEG.EncodeFromImage(bitmap, true); | 183 | imageData = OpenJPEG.EncodeFromImage(bitmap, true); |
181 | } | 184 | } |
182 | 185 | ||
183 | AssetBase ass = new AssetBase(UUID.Random(), "region " + name, (sbyte)AssetType.Texture, regionID.ToString()); | 186 | AssetBase ass = new AssetBase(UUID.Random(), "region " + name, (sbyte)AssetType.Texture, regionID.ToString()); |
184 | 187 | ||
185 | // !!! for now | 188 | // !!! for now |
@@ -257,7 +260,8 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
257 | region.RegionName = (string)hash["region_name"]; | 260 | region.RegionName = (string)hash["region_name"]; |
258 | //m_log.Debug(">> HERE, region_name: " + region.RegionName); | 261 | //m_log.Debug(">> HERE, region_name: " + region.RegionName); |
259 | } | 262 | } |
260 | if (hash["hostname"] != null) { | 263 | if (hash["hostname"] != null) |
264 | { | ||
261 | region.ExternalHostName = (string)hash["hostname"]; | 265 | region.ExternalHostName = (string)hash["hostname"]; |
262 | //m_log.Debug(">> HERE, hostname: " + region.ExternalHostName); | 266 | //m_log.Debug(">> HERE, hostname: " + region.ExternalHostName); |
263 | } | 267 | } |
@@ -275,10 +279,10 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
275 | region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p); | 279 | region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p); |
276 | //m_log.Debug(">> HERE, internal_port: " + region.InternalEndPoint); | 280 | //m_log.Debug(">> HERE, internal_port: " + region.InternalEndPoint); |
277 | } | 281 | } |
278 | 282 | ||
279 | if (hash["server_uri"] != null) | 283 | if (hash["server_uri"] != null) |
280 | { | 284 | { |
281 | region.ServerURI = (string) hash["server_uri"]; | 285 | region.ServerURI = (string)hash["server_uri"]; |
282 | //m_log.Debug(">> HERE, server_uri: " + region.ServerURI); | 286 | //m_log.Debug(">> HERE, server_uri: " + region.ServerURI); |
283 | } | 287 | } |
284 | 288 | ||
@@ -295,55 +299,5 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
295 | 299 | ||
296 | return null; | 300 | return null; |
297 | } | 301 | } |
298 | |||
299 | public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string myipaddress, out string reason) | ||
300 | { | ||
301 | // m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: CreateAgent start"); | ||
302 | |||
303 | myipaddress = String.Empty; | ||
304 | reason = String.Empty; | ||
305 | |||
306 | if (destination == null) | ||
307 | { | ||
308 | m_log.Debug("[GATEKEEPER SERVICE CONNECTOR]: Given destination is null"); | ||
309 | return false; | ||
310 | } | ||
311 | |||
312 | string uri = destination.ServerURI + AgentPath() + aCircuit.AgentID + "/"; | ||
313 | |||
314 | try | ||
315 | { | ||
316 | OSDMap args = aCircuit.PackAgentCircuitData(); | ||
317 | |||
318 | args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString()); | ||
319 | args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString()); | ||
320 | args["destination_name"] = OSD.FromString(destination.RegionName); | ||
321 | args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString()); | ||
322 | args["teleport_flags"] = OSD.FromString(flags.ToString()); | ||
323 | |||
324 | OSDMap result = WebUtil.PostToService(uri, args, 80000); | ||
325 | if (result["Success"].AsBoolean()) | ||
326 | { | ||
327 | OSDMap unpacked = (OSDMap)result["_Result"]; | ||
328 | |||
329 | if (unpacked != null) | ||
330 | { | ||
331 | reason = unpacked["reason"].AsString(); | ||
332 | myipaddress = unpacked["your_ip"].AsString(); | ||
333 | return unpacked["success"].AsBoolean(); | ||
334 | } | ||
335 | } | ||
336 | |||
337 | reason = result["Message"] != null ? result["Message"].AsString() : "error"; | ||
338 | return false; | ||
339 | } | ||
340 | catch (Exception e) | ||
341 | { | ||
342 | m_log.Warn("[REMOTE SIMULATION CONNECTOR]: CreateAgent failed with exception: " + e.ToString()); | ||
343 | reason = e.Message; | ||
344 | } | ||
345 | |||
346 | return false; | ||
347 | } | ||
348 | } | 302 | } |
349 | } | 303 | } |
diff --git a/OpenSim/Services/Connectors/Hypergrid/HGFriendsServicesConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HGFriendsServicesConnector.cs index e984a54..622d4e1 100644 --- a/OpenSim/Services/Connectors/Hypergrid/HGFriendsServicesConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/HGFriendsServicesConnector.cs | |||
@@ -277,7 +277,7 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
277 | { | 277 | { |
278 | reply = SynchronousRestFormsRequester.MakeRequest("POST", | 278 | reply = SynchronousRestFormsRequester.MakeRequest("POST", |
279 | uri, | 279 | uri, |
280 | ServerUtils.BuildQueryString(sendData)); | 280 | ServerUtils.BuildQueryString(sendData), 15); |
281 | } | 281 | } |
282 | catch (Exception e) | 282 | catch (Exception e) |
283 | { | 283 | { |
diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs index d7e38f1..5f5b7a7 100644 --- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs | |||
@@ -44,13 +44,14 @@ using Nini.Config; | |||
44 | 44 | ||
45 | namespace OpenSim.Services.Connectors.Hypergrid | 45 | namespace OpenSim.Services.Connectors.Hypergrid |
46 | { | 46 | { |
47 | public class UserAgentServiceConnector : IUserAgentService | 47 | public class UserAgentServiceConnector : SimulationServiceConnector, IUserAgentService |
48 | { | 48 | { |
49 | private static readonly ILog m_log = | 49 | private static readonly ILog m_log = |
50 | LogManager.GetLogger( | 50 | LogManager.GetLogger( |
51 | MethodBase.GetCurrentMethod().DeclaringType); | 51 | MethodBase.GetCurrentMethod().DeclaringType); |
52 | 52 | ||
53 | string m_ServerURL; | 53 | private string m_ServerURL; |
54 | private GridRegion m_Gatekeeper; | ||
54 | 55 | ||
55 | public UserAgentServiceConnector(string url) : this(url, true) | 56 | public UserAgentServiceConnector(string url) : this(url, true) |
56 | { | 57 | { |
@@ -102,9 +103,15 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
102 | m_log.DebugFormat("[USER AGENT CONNECTOR]: UserAgentServiceConnector started for {0}", m_ServerURL); | 103 | m_log.DebugFormat("[USER AGENT CONNECTOR]: UserAgentServiceConnector started for {0}", m_ServerURL); |
103 | } | 104 | } |
104 | 105 | ||
106 | protected override string AgentPath() | ||
107 | { | ||
108 | return "homeagent/"; | ||
109 | } | ||
105 | 110 | ||
106 | // The Login service calls this interface with a non-null [client] ipaddress | 111 | // The Login service calls this interface with fromLogin=true |
107 | public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, IPEndPoint ipaddress, out string reason) | 112 | // Sims call it with fromLogin=false |
113 | // Either way, this is verified by the handler | ||
114 | public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, bool fromLogin, out string reason) | ||
108 | { | 115 | { |
109 | reason = String.Empty; | 116 | reason = String.Empty; |
110 | 117 | ||
@@ -115,119 +122,34 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
115 | return false; | 122 | return false; |
116 | } | 123 | } |
117 | 124 | ||
118 | string uri = m_ServerURL + "homeagent/" + aCircuit.AgentID + "/"; | 125 | GridRegion home = new GridRegion(); |
119 | 126 | home.ServerURI = m_ServerURL; | |
120 | Console.WriteLine(" >>> LoginAgentToGrid <<< " + uri); | 127 | home.RegionID = destination.RegionID; |
121 | 128 | home.RegionLocX = destination.RegionLocX; | |
122 | HttpWebRequest AgentCreateRequest = (HttpWebRequest)WebRequest.Create(uri); | 129 | home.RegionLocY = destination.RegionLocY; |
123 | AgentCreateRequest.Method = "POST"; | ||
124 | AgentCreateRequest.ContentType = "application/json"; | ||
125 | AgentCreateRequest.Timeout = 10000; | ||
126 | //AgentCreateRequest.KeepAlive = false; | ||
127 | //AgentCreateRequest.Headers.Add("Authorization", authKey); | ||
128 | |||
129 | // Fill it in | ||
130 | OSDMap args = PackCreateAgentArguments(aCircuit, gatekeeper, destination, ipaddress); | ||
131 | |||
132 | string strBuffer = ""; | ||
133 | byte[] buffer = new byte[1]; | ||
134 | try | ||
135 | { | ||
136 | strBuffer = OSDParser.SerializeJsonString(args); | ||
137 | Encoding str = Util.UTF8; | ||
138 | buffer = str.GetBytes(strBuffer); | ||
139 | |||
140 | } | ||
141 | catch (Exception e) | ||
142 | { | ||
143 | m_log.WarnFormat("[USER AGENT CONNECTOR]: Exception thrown on serialization of ChildCreate: {0}", e.Message); | ||
144 | // ignore. buffer will be empty, caller should check. | ||
145 | } | ||
146 | |||
147 | Stream os = null; | ||
148 | try | ||
149 | { // send the Post | ||
150 | AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send | ||
151 | os = AgentCreateRequest.GetRequestStream(); | ||
152 | os.Write(buffer, 0, strBuffer.Length); //Send it | ||
153 | m_log.InfoFormat("[USER AGENT CONNECTOR]: Posted CreateAgent request to remote sim {0}, region {1}, x={2} y={3}", | ||
154 | uri, destination.RegionName, destination.RegionLocX, destination.RegionLocY); | ||
155 | } | ||
156 | //catch (WebException ex) | ||
157 | catch | ||
158 | { | ||
159 | //m_log.InfoFormat("[USER AGENT CONNECTOR]: Bad send on ChildAgentUpdate {0}", ex.Message); | ||
160 | reason = "cannot contact remote region"; | ||
161 | return false; | ||
162 | } | ||
163 | finally | ||
164 | { | ||
165 | if (os != null) | ||
166 | os.Close(); | ||
167 | } | ||
168 | |||
169 | // Let's wait for the response | ||
170 | //m_log.Info("[USER AGENT CONNECTOR]: Waiting for a reply after DoCreateChildAgentCall"); | ||
171 | 130 | ||
172 | try | 131 | m_Gatekeeper = gatekeeper; |
173 | { | ||
174 | using (WebResponse webResponse = AgentCreateRequest.GetResponse()) | ||
175 | { | ||
176 | if (webResponse == null) | ||
177 | { | ||
178 | m_log.Info("[USER AGENT CONNECTOR]: Null reply on DoCreateChildAgentCall post"); | ||
179 | } | ||
180 | else | ||
181 | { | ||
182 | using (Stream s = webResponse.GetResponseStream()) | ||
183 | { | ||
184 | using (StreamReader sr = new StreamReader(s)) | ||
185 | { | ||
186 | string response = sr.ReadToEnd().Trim(); | ||
187 | m_log.InfoFormat("[USER AGENT CONNECTOR]: DoCreateChildAgentCall reply was {0} ", response); | ||
188 | |||
189 | if (!String.IsNullOrEmpty(response)) | ||
190 | { | ||
191 | try | ||
192 | { | ||
193 | // we assume we got an OSDMap back | ||
194 | OSDMap r = Util.GetOSDMap(response); | ||
195 | bool success = r["success"].AsBoolean(); | ||
196 | reason = r["reason"].AsString(); | ||
197 | return success; | ||
198 | } | ||
199 | catch (NullReferenceException e) | ||
200 | { | ||
201 | m_log.InfoFormat("[USER AGENT CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", e.Message); | ||
202 | |||
203 | // check for old style response | ||
204 | if (response.ToLower().StartsWith("true")) | ||
205 | return true; | ||
206 | |||
207 | return false; | ||
208 | } | ||
209 | } | ||
210 | } | ||
211 | } | ||
212 | } | ||
213 | } | ||
214 | } | ||
215 | catch (WebException ex) | ||
216 | { | ||
217 | m_log.InfoFormat("[USER AGENT CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", ex.Message); | ||
218 | reason = "Destination did not reply"; | ||
219 | return false; | ||
220 | } | ||
221 | 132 | ||
222 | return true; | 133 | Console.WriteLine(" >>> LoginAgentToGrid <<< " + home.ServerURI); |
223 | 134 | ||
135 | uint flags = fromLogin ? (uint)TeleportFlags.ViaLogin : (uint)TeleportFlags.ViaHome; | ||
136 | return CreateAgent(home, aCircuit, flags, out reason); | ||
224 | } | 137 | } |
225 | 138 | ||
226 | 139 | ||
227 | // The simulators call this interface | 140 | // The simulators call this interface |
228 | public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, out string reason) | 141 | public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, out string reason) |
229 | { | 142 | { |
230 | return LoginAgentToGrid(aCircuit, gatekeeper, destination, null, out reason); | 143 | return LoginAgentToGrid(aCircuit, gatekeeper, destination, false, out reason); |
144 | } | ||
145 | |||
146 | protected override void PackData(OSDMap args, AgentCircuitData aCircuit, GridRegion destination, uint flags) | ||
147 | { | ||
148 | base.PackData(args, aCircuit, destination, flags); | ||
149 | args["gatekeeper_serveruri"] = OSD.FromString(m_Gatekeeper.ServerURI); | ||
150 | args["gatekeeper_host"] = OSD.FromString(m_Gatekeeper.ExternalHostName); | ||
151 | args["gatekeeper_port"] = OSD.FromString(m_Gatekeeper.HttpPort.ToString()); | ||
152 | args["destination_serveruri"] = OSD.FromString(destination.ServerURI); | ||
231 | } | 153 | } |
232 | 154 | ||
233 | protected OSDMap PackCreateAgentArguments(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, IPEndPoint ipaddress) | 155 | protected OSDMap PackCreateAgentArguments(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, IPEndPoint ipaddress) |
diff --git a/OpenSim/Services/Connectors/InstantMessage/InstantMessageServiceConnector.cs b/OpenSim/Services/Connectors/InstantMessage/InstantMessageServiceConnector.cs index dbce9f6..e19c23d 100644 --- a/OpenSim/Services/Connectors/InstantMessage/InstantMessageServiceConnector.cs +++ b/OpenSim/Services/Connectors/InstantMessage/InstantMessageServiceConnector.cs | |||
@@ -123,6 +123,7 @@ namespace OpenSim.Services.Connectors.InstantMessage | |||
123 | gim["position_z"] = msg.Position.Z.ToString(); | 123 | gim["position_z"] = msg.Position.Z.ToString(); |
124 | gim["region_id"] = msg.RegionID.ToString(); | 124 | gim["region_id"] = msg.RegionID.ToString(); |
125 | gim["binary_bucket"] = Convert.ToBase64String(msg.binaryBucket, Base64FormattingOptions.None); | 125 | gim["binary_bucket"] = Convert.ToBase64String(msg.binaryBucket, Base64FormattingOptions.None); |
126 | gim["region_id"] = new UUID(msg.RegionID).ToString(); | ||
126 | 127 | ||
127 | return gim; | 128 | return gim; |
128 | } | 129 | } |
diff --git a/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs b/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs index 44f5e01..36d4ae2 100644 --- a/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/XInventoryServicesConnector.cs | |||
@@ -84,6 +84,30 @@ namespace OpenSim.Services.Connectors | |||
84 | m_ServerURI = serviceURI; | 84 | m_ServerURI = serviceURI; |
85 | } | 85 | } |
86 | 86 | ||
87 | private bool CheckReturn(Dictionary<string, object> ret) | ||
88 | { | ||
89 | if (ret == null) | ||
90 | return false; | ||
91 | |||
92 | if (ret.Count == 0) | ||
93 | return false; | ||
94 | |||
95 | if (ret.ContainsKey("RESULT")) | ||
96 | { | ||
97 | if (ret["RESULT"] is string) | ||
98 | { | ||
99 | bool result; | ||
100 | |||
101 | if (bool.TryParse((string)ret["RESULT"], out result)) | ||
102 | return result; | ||
103 | |||
104 | return false; | ||
105 | } | ||
106 | } | ||
107 | |||
108 | return true; | ||
109 | } | ||
110 | |||
87 | public bool CreateUserInventory(UUID principalID) | 111 | public bool CreateUserInventory(UUID principalID) |
88 | { | 112 | { |
89 | Dictionary<string,object> ret = MakeRequest("CREATEUSERINVENTORY", | 113 | Dictionary<string,object> ret = MakeRequest("CREATEUSERINVENTORY", |
@@ -91,12 +115,7 @@ namespace OpenSim.Services.Connectors | |||
91 | { "PRINCIPAL", principalID.ToString() } | 115 | { "PRINCIPAL", principalID.ToString() } |
92 | }); | 116 | }); |
93 | 117 | ||
94 | if (ret == null) | 118 | return CheckReturn(ret); |
95 | return false; | ||
96 | if (ret.Count == 0) | ||
97 | return false; | ||
98 | |||
99 | return bool.Parse(ret["RESULT"].ToString()); | ||
100 | } | 119 | } |
101 | 120 | ||
102 | public List<InventoryFolderBase> GetInventorySkeleton(UUID principalID) | 121 | public List<InventoryFolderBase> GetInventorySkeleton(UUID principalID) |
@@ -106,9 +125,7 @@ namespace OpenSim.Services.Connectors | |||
106 | { "PRINCIPAL", principalID.ToString() } | 125 | { "PRINCIPAL", principalID.ToString() } |
107 | }); | 126 | }); |
108 | 127 | ||
109 | if (ret == null) | 128 | if (!CheckReturn(ret)) |
110 | return null; | ||
111 | if (ret.Count == 0) | ||
112 | return null; | 129 | return null; |
113 | 130 | ||
114 | Dictionary<string, object> folders = (Dictionary<string, object>)ret["FOLDERS"]; | 131 | Dictionary<string, object> folders = (Dictionary<string, object>)ret["FOLDERS"]; |
@@ -135,9 +152,7 @@ namespace OpenSim.Services.Connectors | |||
135 | { "PRINCIPAL", principalID.ToString() } | 152 | { "PRINCIPAL", principalID.ToString() } |
136 | }); | 153 | }); |
137 | 154 | ||
138 | if (ret == null) | 155 | if (!CheckReturn(ret)) |
139 | return null; | ||
140 | if (ret.Count == 0) | ||
141 | return null; | 156 | return null; |
142 | 157 | ||
143 | return BuildFolder((Dictionary<string, object>)ret["folder"]); | 158 | return BuildFolder((Dictionary<string, object>)ret["folder"]); |
@@ -151,9 +166,7 @@ namespace OpenSim.Services.Connectors | |||
151 | { "TYPE", ((int)type).ToString() } | 166 | { "TYPE", ((int)type).ToString() } |
152 | }); | 167 | }); |
153 | 168 | ||
154 | if (ret == null) | 169 | if (!CheckReturn(ret)) |
155 | return null; | ||
156 | if (ret.Count == 0) | ||
157 | return null; | 170 | return null; |
158 | 171 | ||
159 | return BuildFolder((Dictionary<string, object>)ret["folder"]); | 172 | return BuildFolder((Dictionary<string, object>)ret["folder"]); |
@@ -174,9 +187,7 @@ namespace OpenSim.Services.Connectors | |||
174 | { "FOLDER", folderID.ToString() } | 187 | { "FOLDER", folderID.ToString() } |
175 | }); | 188 | }); |
176 | 189 | ||
177 | if (ret == null) | 190 | if (!CheckReturn(ret)) |
178 | return null; | ||
179 | if (ret.Count == 0) | ||
180 | return null; | 191 | return null; |
181 | 192 | ||
182 | Dictionary<string,object> folders = | 193 | Dictionary<string,object> folders = |
@@ -205,9 +216,7 @@ namespace OpenSim.Services.Connectors | |||
205 | { "FOLDER", folderID.ToString() } | 216 | { "FOLDER", folderID.ToString() } |
206 | }); | 217 | }); |
207 | 218 | ||
208 | if (ret == null) | 219 | if (!CheckReturn(ret)) |
209 | return null; | ||
210 | if (ret.Count == 0) | ||
211 | return null; | 220 | return null; |
212 | 221 | ||
213 | Dictionary<string, object> items = (Dictionary<string, object>)ret["ITEMS"]; | 222 | Dictionary<string, object> items = (Dictionary<string, object>)ret["ITEMS"]; |
@@ -230,10 +239,7 @@ namespace OpenSim.Services.Connectors | |||
230 | { "ID", folder.ID.ToString() } | 239 | { "ID", folder.ID.ToString() } |
231 | }); | 240 | }); |
232 | 241 | ||
233 | if (ret == null) | 242 | return CheckReturn(ret); |
234 | return false; | ||
235 | |||
236 | return bool.Parse(ret["RESULT"].ToString()); | ||
237 | } | 243 | } |
238 | 244 | ||
239 | public bool UpdateFolder(InventoryFolderBase folder) | 245 | public bool UpdateFolder(InventoryFolderBase folder) |
@@ -248,10 +254,7 @@ namespace OpenSim.Services.Connectors | |||
248 | { "ID", folder.ID.ToString() } | 254 | { "ID", folder.ID.ToString() } |
249 | }); | 255 | }); |
250 | 256 | ||
251 | if (ret == null) | 257 | return CheckReturn(ret); |
252 | return false; | ||
253 | |||
254 | return bool.Parse(ret["RESULT"].ToString()); | ||
255 | } | 258 | } |
256 | 259 | ||
257 | public bool MoveFolder(InventoryFolderBase folder) | 260 | public bool MoveFolder(InventoryFolderBase folder) |
@@ -263,10 +266,7 @@ namespace OpenSim.Services.Connectors | |||
263 | { "PRINCIPAL", folder.Owner.ToString() } | 266 | { "PRINCIPAL", folder.Owner.ToString() } |
264 | }); | 267 | }); |
265 | 268 | ||
266 | if (ret == null) | 269 | return CheckReturn(ret); |
267 | return false; | ||
268 | |||
269 | return bool.Parse(ret["RESULT"].ToString()); | ||
270 | } | 270 | } |
271 | 271 | ||
272 | public bool DeleteFolders(UUID principalID, List<UUID> folderIDs) | 272 | public bool DeleteFolders(UUID principalID, List<UUID> folderIDs) |
@@ -282,10 +282,7 @@ namespace OpenSim.Services.Connectors | |||
282 | { "FOLDERS", slist } | 282 | { "FOLDERS", slist } |
283 | }); | 283 | }); |
284 | 284 | ||
285 | if (ret == null) | 285 | return CheckReturn(ret); |
286 | return false; | ||
287 | |||
288 | return bool.Parse(ret["RESULT"].ToString()); | ||
289 | } | 286 | } |
290 | 287 | ||
291 | public bool PurgeFolder(InventoryFolderBase folder) | 288 | public bool PurgeFolder(InventoryFolderBase folder) |
@@ -295,10 +292,7 @@ namespace OpenSim.Services.Connectors | |||
295 | { "ID", folder.ID.ToString() } | 292 | { "ID", folder.ID.ToString() } |
296 | }); | 293 | }); |
297 | 294 | ||
298 | if (ret == null) | 295 | return CheckReturn(ret); |
299 | return false; | ||
300 | |||
301 | return bool.Parse(ret["RESULT"].ToString()); | ||
302 | } | 296 | } |
303 | 297 | ||
304 | public bool AddItem(InventoryItemBase item) | 298 | public bool AddItem(InventoryItemBase item) |
@@ -330,10 +324,7 @@ namespace OpenSim.Services.Connectors | |||
330 | { "CreationDate", item.CreationDate.ToString() } | 324 | { "CreationDate", item.CreationDate.ToString() } |
331 | }); | 325 | }); |
332 | 326 | ||
333 | if (ret == null) | 327 | return CheckReturn(ret); |
334 | return false; | ||
335 | |||
336 | return bool.Parse(ret["RESULT"].ToString()); | ||
337 | } | 328 | } |
338 | 329 | ||
339 | public bool UpdateItem(InventoryItemBase item) | 330 | public bool UpdateItem(InventoryItemBase item) |
@@ -365,10 +356,7 @@ namespace OpenSim.Services.Connectors | |||
365 | { "CreationDate", item.CreationDate.ToString() } | 356 | { "CreationDate", item.CreationDate.ToString() } |
366 | }); | 357 | }); |
367 | 358 | ||
368 | if (ret == null) | 359 | return CheckReturn(ret); |
369 | return false; | ||
370 | |||
371 | return bool.Parse(ret["RESULT"].ToString()); | ||
372 | } | 360 | } |
373 | 361 | ||
374 | public bool MoveItems(UUID principalID, List<InventoryItemBase> items) | 362 | public bool MoveItems(UUID principalID, List<InventoryItemBase> items) |
@@ -389,10 +377,7 @@ namespace OpenSim.Services.Connectors | |||
389 | { "DESTLIST", destlist } | 377 | { "DESTLIST", destlist } |
390 | }); | 378 | }); |
391 | 379 | ||
392 | if (ret == null) | 380 | return CheckReturn(ret); |
393 | return false; | ||
394 | |||
395 | return bool.Parse(ret["RESULT"].ToString()); | ||
396 | } | 381 | } |
397 | 382 | ||
398 | public bool DeleteItems(UUID principalID, List<UUID> itemIDs) | 383 | public bool DeleteItems(UUID principalID, List<UUID> itemIDs) |
@@ -408,10 +393,7 @@ namespace OpenSim.Services.Connectors | |||
408 | { "ITEMS", slist } | 393 | { "ITEMS", slist } |
409 | }); | 394 | }); |
410 | 395 | ||
411 | if (ret == null) | 396 | return CheckReturn(ret); |
412 | return false; | ||
413 | |||
414 | return bool.Parse(ret["RESULT"].ToString()); | ||
415 | } | 397 | } |
416 | 398 | ||
417 | public InventoryItemBase GetItem(InventoryItemBase item) | 399 | public InventoryItemBase GetItem(InventoryItemBase item) |
@@ -423,9 +405,7 @@ namespace OpenSim.Services.Connectors | |||
423 | { "ID", item.ID.ToString() } | 405 | { "ID", item.ID.ToString() } |
424 | }); | 406 | }); |
425 | 407 | ||
426 | if (ret == null) | 408 | if (!CheckReturn(ret)) |
427 | return null; | ||
428 | if (ret.Count == 0) | ||
429 | return null; | 409 | return null; |
430 | 410 | ||
431 | return BuildItem((Dictionary<string, object>)ret["item"]); | 411 | return BuildItem((Dictionary<string, object>)ret["item"]); |
@@ -447,9 +427,7 @@ namespace OpenSim.Services.Connectors | |||
447 | { "ID", folder.ID.ToString() } | 427 | { "ID", folder.ID.ToString() } |
448 | }); | 428 | }); |
449 | 429 | ||
450 | if (ret == null) | 430 | if (!CheckReturn(ret)) |
451 | return null; | ||
452 | if (ret.Count == 0) | ||
453 | return null; | 431 | return null; |
454 | 432 | ||
455 | return BuildFolder((Dictionary<string, object>)ret["folder"]); | 433 | return BuildFolder((Dictionary<string, object>)ret["folder"]); |
@@ -469,7 +447,7 @@ namespace OpenSim.Services.Connectors | |||
469 | { "PRINCIPAL", principalID.ToString() } | 447 | { "PRINCIPAL", principalID.ToString() } |
470 | }); | 448 | }); |
471 | 449 | ||
472 | if (ret == null) | 450 | if (!CheckReturn(ret)) |
473 | return null; | 451 | return null; |
474 | 452 | ||
475 | List<InventoryItemBase> items = new List<InventoryItemBase>(); | 453 | List<InventoryItemBase> items = new List<InventoryItemBase>(); |
@@ -488,10 +466,22 @@ namespace OpenSim.Services.Connectors | |||
488 | { "ASSET", assetID.ToString() } | 466 | { "ASSET", assetID.ToString() } |
489 | }); | 467 | }); |
490 | 468 | ||
469 | // We cannot use CheckReturn() here because valid values for RESULT are "false" (in the case of request failure) or an int | ||
491 | if (ret == null) | 470 | if (ret == null) |
492 | return 0; | 471 | return 0; |
493 | 472 | ||
494 | return int.Parse(ret["RESULT"].ToString()); | 473 | if (ret.ContainsKey("RESULT")) |
474 | { | ||
475 | if (ret["RESULT"] is string) | ||
476 | { | ||
477 | int intResult; | ||
478 | |||
479 | if (int.TryParse ((string)ret["RESULT"], out intResult)) | ||
480 | return intResult; | ||
481 | } | ||
482 | } | ||
483 | |||
484 | return 0; | ||
495 | } | 485 | } |
496 | 486 | ||
497 | public InventoryCollection GetUserInventory(UUID principalID) | 487 | public InventoryCollection GetUserInventory(UUID principalID) |
@@ -508,9 +498,7 @@ namespace OpenSim.Services.Connectors | |||
508 | { "PRINCIPAL", principalID.ToString() } | 498 | { "PRINCIPAL", principalID.ToString() } |
509 | }); | 499 | }); |
510 | 500 | ||
511 | if (ret == null) | 501 | if (!CheckReturn(ret)) |
512 | return null; | ||
513 | if (ret.Count == 0) | ||
514 | return null; | 502 | return null; |
515 | 503 | ||
516 | Dictionary<string, object> folders = | 504 | Dictionary<string, object> folders = |
diff --git a/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs b/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs index b36fa23..245703c 100644 --- a/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs +++ b/OpenSim/Services/Connectors/Neighbour/NeighbourServicesConnector.cs | |||
@@ -98,7 +98,7 @@ namespace OpenSim.Services.Connectors | |||
98 | catch (Exception e) | 98 | catch (Exception e) |
99 | { | 99 | { |
100 | m_log.WarnFormat( | 100 | m_log.WarnFormat( |
101 | "[NEIGHBOUR SERVICE CONNCTOR]: Unable to parse uri {0} to send HelloNeighbour from {1} to {2}. Exception {3}{4}", | 101 | "[NEIGHBOUR SERVICES CONNECTOR]: Unable to parse uri {0} to send HelloNeighbour from {1} to {2}. Exception {3}{4}", |
102 | uri, thisRegion.RegionName, region.RegionName, e.Message, e.StackTrace); | 102 | uri, thisRegion.RegionName, region.RegionName, e.Message, e.StackTrace); |
103 | 103 | ||
104 | return false; | 104 | return false; |
@@ -117,7 +117,7 @@ namespace OpenSim.Services.Connectors | |||
117 | catch (Exception e) | 117 | catch (Exception e) |
118 | { | 118 | { |
119 | m_log.WarnFormat( | 119 | m_log.WarnFormat( |
120 | "[NEIGHBOUR SERVICE CONNCTOR]: PackRegionInfoData failed for HelloNeighbour from {0} to {1}. Exception {2}{3}", | 120 | "[NEIGHBOUR SERVICES CONNECTOR]: PackRegionInfoData failed for HelloNeighbour from {0} to {1}. Exception {2}{3}", |
121 | thisRegion.RegionName, region.RegionName, e.Message, e.StackTrace); | 121 | thisRegion.RegionName, region.RegionName, e.Message, e.StackTrace); |
122 | 122 | ||
123 | return false; | 123 | return false; |
@@ -137,7 +137,7 @@ namespace OpenSim.Services.Connectors | |||
137 | catch (Exception e) | 137 | catch (Exception e) |
138 | { | 138 | { |
139 | m_log.WarnFormat( | 139 | m_log.WarnFormat( |
140 | "[NEIGHBOUR SERVICE CONNCTOR]: Exception thrown on serialization of HelloNeighbour from {0} to {1}. Exception {2}{3}", | 140 | "[NEIGHBOUR SERVICES CONNECTOR]: Exception thrown on serialization of HelloNeighbour from {0} to {1}. Exception {2}{3}", |
141 | thisRegion.RegionName, region.RegionName, e.Message, e.StackTrace); | 141 | thisRegion.RegionName, region.RegionName, e.Message, e.StackTrace); |
142 | 142 | ||
143 | return false; | 143 | return false; |
@@ -175,7 +175,7 @@ namespace OpenSim.Services.Connectors | |||
175 | if (webResponse == null) | 175 | if (webResponse == null) |
176 | { | 176 | { |
177 | m_log.DebugFormat( | 177 | m_log.DebugFormat( |
178 | "[REST COMMS]: Null reply on DoHelloNeighbourCall post from {0} to {1}", | 178 | "[NEIGHBOUR SERVICES CONNECTOR]: Null reply on DoHelloNeighbourCall post from {0} to {1}", |
179 | thisRegion.RegionName, region.RegionName); | 179 | thisRegion.RegionName, region.RegionName); |
180 | } | 180 | } |
181 | 181 | ||
@@ -193,7 +193,7 @@ namespace OpenSim.Services.Connectors | |||
193 | catch (Exception e) | 193 | catch (Exception e) |
194 | { | 194 | { |
195 | m_log.WarnFormat( | 195 | m_log.WarnFormat( |
196 | "[NEIGHBOUR SERVICE CONNCTOR]: Exception on reply of DoHelloNeighbourCall from {0} back to {1}. Exception {2}{3}", | 196 | "[NEIGHBOUR SERVICES CONNECTOR]: Exception on reply of DoHelloNeighbourCall from {0} back to {1}. Exception {2}{3}", |
197 | region.RegionName, thisRegion.RegionName, e.Message, e.StackTrace); | 197 | region.RegionName, thisRegion.RegionName, e.Message, e.StackTrace); |
198 | 198 | ||
199 | return false; | 199 | return false; |
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs index 74b980c..6f8d9ed 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Collections.Specialized; | ||
30 | using System.IO; | 31 | using System.IO; |
31 | using System.Net; | 32 | using System.Net; |
32 | using System.Reflection; | 33 | using System.Reflection; |
@@ -122,7 +123,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
122 | m_Enabled = true; | 123 | m_Enabled = true; |
123 | } | 124 | } |
124 | 125 | ||
125 | #region IAssetService | 126 | #region IAssetService |
126 | 127 | ||
127 | public AssetBase Get(string id) | 128 | public AssetBase Get(string id) |
128 | { | 129 | { |
@@ -140,8 +141,9 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
140 | return asset; | 141 | return asset; |
141 | } | 142 | } |
142 | 143 | ||
143 | return GetRemote(id); | 144 | return SimianGetOperation(id); |
144 | } | 145 | } |
146 | |||
145 | 147 | ||
146 | public AssetBase GetCached(string id) | 148 | public AssetBase GetCached(string id) |
147 | { | 149 | { |
@@ -164,8 +166,6 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
164 | throw new InvalidOperationException(); | 166 | throw new InvalidOperationException(); |
165 | } | 167 | } |
166 | 168 | ||
167 | AssetMetadata metadata = null; | ||
168 | |||
169 | // Cache fetch | 169 | // Cache fetch |
170 | if (m_cache != null) | 170 | if (m_cache != null) |
171 | { | 171 | { |
@@ -174,50 +174,18 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
174 | return asset.Metadata; | 174 | return asset.Metadata; |
175 | } | 175 | } |
176 | 176 | ||
177 | Uri url; | 177 | // return GetRemoteMetadata(id); |
178 | 178 | return SimianGetMetadataOperation(id); | |
179 | // Determine if id is an absolute URL or a grid-relative UUID | ||
180 | if (!Uri.TryCreate(id, UriKind.Absolute, out url)) | ||
181 | url = new Uri(m_serverUrl + id); | ||
182 | |||
183 | try | ||
184 | { | ||
185 | HttpWebRequest request = UntrustedHttpWebRequest.Create(url); | ||
186 | request.Method = "HEAD"; | ||
187 | |||
188 | using (WebResponse response = request.GetResponse()) | ||
189 | { | ||
190 | using (Stream responseStream = response.GetResponseStream()) | ||
191 | { | ||
192 | // Create the metadata object | ||
193 | metadata = new AssetMetadata(); | ||
194 | metadata.ContentType = response.ContentType; | ||
195 | metadata.ID = id; | ||
196 | |||
197 | UUID uuid; | ||
198 | if (UUID.TryParse(id, out uuid)) | ||
199 | metadata.FullID = uuid; | ||
200 | |||
201 | string lastModifiedStr = response.Headers.Get("Last-Modified"); | ||
202 | if (!String.IsNullOrEmpty(lastModifiedStr)) | ||
203 | { | ||
204 | DateTime lastModified; | ||
205 | if (DateTime.TryParse(lastModifiedStr, out lastModified)) | ||
206 | metadata.CreationDate = lastModified; | ||
207 | } | ||
208 | } | ||
209 | } | ||
210 | } | ||
211 | catch (Exception ex) | ||
212 | { | ||
213 | m_log.Warn("[SIMIAN ASSET CONNECTOR]: Asset HEAD from " + url + " failed: " + ex.Message); | ||
214 | } | ||
215 | |||
216 | return metadata; | ||
217 | } | 179 | } |
218 | 180 | ||
219 | public byte[] GetData(string id) | 181 | public byte[] GetData(string id) |
220 | { | 182 | { |
183 | if (String.IsNullOrEmpty(m_serverUrl)) | ||
184 | { | ||
185 | m_log.Error("[SIMIAN ASSET CONNECTOR]: No AssetServerURI configured"); | ||
186 | throw new InvalidOperationException(); | ||
187 | } | ||
188 | |||
221 | AssetBase asset = Get(id); | 189 | AssetBase asset = Get(id); |
222 | 190 | ||
223 | if (asset != null) | 191 | if (asset != null) |
@@ -255,7 +223,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
255 | Util.FireAndForget( | 223 | Util.FireAndForget( |
256 | delegate(object o) | 224 | delegate(object o) |
257 | { | 225 | { |
258 | AssetBase asset = GetRemote(id); | 226 | AssetBase asset = SimianGetOperation(id); |
259 | handler(id, sender, asset); | 227 | handler(id, sender, asset); |
260 | } | 228 | } |
261 | ); | 229 | ); |
@@ -278,7 +246,6 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
278 | } | 246 | } |
279 | 247 | ||
280 | bool storedInCache = false; | 248 | bool storedInCache = false; |
281 | string errorMessage = null; | ||
282 | 249 | ||
283 | // AssetID handling | 250 | // AssetID handling |
284 | if (String.IsNullOrEmpty(asset.ID) || asset.ID == ZeroID) | 251 | if (String.IsNullOrEmpty(asset.ID) || asset.ID == ZeroID) |
@@ -307,83 +274,9 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
307 | return asset.ID; | 274 | return asset.ID; |
308 | } | 275 | } |
309 | 276 | ||
310 | // Distinguish public and private assets | 277 | return SimianStoreOperation(asset); |
311 | bool isPublic = true; | ||
312 | switch ((AssetType)asset.Type) | ||
313 | { | ||
314 | case AssetType.CallingCard: | ||
315 | case AssetType.Gesture: | ||
316 | case AssetType.LSLBytecode: | ||
317 | case AssetType.LSLText: | ||
318 | isPublic = false; | ||
319 | break; | ||
320 | } | ||
321 | |||
322 | // Make sure ContentType is set | ||
323 | if (String.IsNullOrEmpty(asset.Metadata.ContentType)) | ||
324 | asset.Metadata.ContentType = SLUtil.SLAssetTypeToContentType(asset.Type); | ||
325 | |||
326 | // Build the remote storage request | ||
327 | List<MultipartForm.Element> postParameters = new List<MultipartForm.Element>() | ||
328 | { | ||
329 | new MultipartForm.Parameter("AssetID", asset.FullID.ToString()), | ||
330 | new MultipartForm.Parameter("CreatorID", asset.Metadata.CreatorID), | ||
331 | new MultipartForm.Parameter("Temporary", asset.Temporary ? "1" : "0"), | ||
332 | new MultipartForm.Parameter("Public", isPublic ? "1" : "0"), | ||
333 | new MultipartForm.File("Asset", asset.Name, asset.Metadata.ContentType, asset.Data) | ||
334 | }; | ||
335 | |||
336 | // Make the remote storage request | ||
337 | try | ||
338 | { | ||
339 | // Simian does not require the asset ID to be in the URL because it's in the post data. | ||
340 | // By appending it to the URL also, we allow caching proxies (squid) to invalidate asset URLs | ||
341 | HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_serverUrl + asset.FullID.ToString()); | ||
342 | |||
343 | using (HttpWebResponse response = MultipartForm.Post(request, postParameters)) | ||
344 | { | ||
345 | using (Stream responseStream = response.GetResponseStream()) | ||
346 | { | ||
347 | string responseStr = null; | ||
348 | |||
349 | try | ||
350 | { | ||
351 | responseStr = responseStream.GetStreamString(); | ||
352 | OSD responseOSD = OSDParser.Deserialize(responseStr); | ||
353 | if (responseOSD.Type == OSDType.Map) | ||
354 | { | ||
355 | OSDMap responseMap = (OSDMap)responseOSD; | ||
356 | if (responseMap["Success"].AsBoolean()) | ||
357 | return asset.ID; | ||
358 | else | ||
359 | errorMessage = "Upload failed: " + responseMap["Message"].AsString(); | ||
360 | } | ||
361 | else | ||
362 | { | ||
363 | errorMessage = "Response format was invalid:\n" + responseStr; | ||
364 | } | ||
365 | } | ||
366 | catch (Exception ex) | ||
367 | { | ||
368 | if (!String.IsNullOrEmpty(responseStr)) | ||
369 | errorMessage = "Failed to parse the response:\n" + responseStr; | ||
370 | else | ||
371 | errorMessage = "Failed to retrieve the response: " + ex.Message; | ||
372 | } | ||
373 | } | ||
374 | } | ||
375 | } | ||
376 | catch (WebException ex) | ||
377 | { | ||
378 | errorMessage = ex.Message; | ||
379 | } | ||
380 | |||
381 | m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: Failed to store asset \"{0}\" ({1}, {2}): {3}", | ||
382 | asset.Name, asset.ID, asset.Metadata.ContentType, errorMessage); | ||
383 | |||
384 | return null; | ||
385 | } | 278 | } |
386 | 279 | ||
387 | /// <summary> | 280 | /// <summary> |
388 | /// Update an asset's content | 281 | /// Update an asset's content |
389 | /// </summary> | 282 | /// </summary> |
@@ -393,11 +286,17 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
393 | /// <returns></returns> | 286 | /// <returns></returns> |
394 | public bool UpdateContent(string id, byte[] data) | 287 | public bool UpdateContent(string id, byte[] data) |
395 | { | 288 | { |
289 | if (String.IsNullOrEmpty(m_serverUrl)) | ||
290 | { | ||
291 | m_log.Error("[SIMIAN ASSET CONNECTOR]: No AssetServerURI configured"); | ||
292 | throw new InvalidOperationException(); | ||
293 | } | ||
294 | |||
396 | AssetBase asset = Get(id); | 295 | AssetBase asset = Get(id); |
397 | 296 | ||
398 | if (asset == null) | 297 | if (asset == null) |
399 | { | 298 | { |
400 | m_log.Warn("[SIMIAN ASSET CONNECTOR]: Failed to fetch asset " + id + " for updating"); | 299 | m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: Failed to fetch asset {0} for updating", id); |
401 | return false; | 300 | return false; |
402 | } | 301 | } |
403 | 302 | ||
@@ -420,83 +319,347 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
420 | throw new InvalidOperationException(); | 319 | throw new InvalidOperationException(); |
421 | } | 320 | } |
422 | 321 | ||
423 | //string errorMessage = String.Empty; | ||
424 | string url = m_serverUrl + id; | ||
425 | |||
426 | if (m_cache != null) | 322 | if (m_cache != null) |
427 | m_cache.Expire(id); | 323 | m_cache.Expire(id); |
428 | 324 | ||
325 | return SimianDeleteOperation(id); | ||
326 | } | ||
327 | |||
328 | #endregion IAssetService | ||
329 | |||
330 | #region SimianOperations | ||
331 | /// <summary> | ||
332 | /// Invokes the xRemoveAsset operation on the simian server to delete an asset | ||
333 | /// </summary> | ||
334 | /// <param name="id"></param> | ||
335 | /// <returns></returns> | ||
336 | private bool SimianDeleteOperation(string id) | ||
337 | { | ||
429 | try | 338 | try |
430 | { | 339 | { |
431 | HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); | 340 | NameValueCollection requestArgs = new NameValueCollection |
432 | request.Method = "DELETE"; | 341 | { |
342 | { "RequestMethod", "xRemoveAsset" }, | ||
343 | { "AssetID", id } | ||
344 | }; | ||
433 | 345 | ||
434 | using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) | 346 | OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs); |
347 | if (! response["Success"].AsBoolean()) | ||
435 | { | 348 | { |
436 | if (response.StatusCode != HttpStatusCode.NoContent) | 349 | m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: failed to delete asset; {0}",response["Message"].AsString()); |
437 | { | 350 | return false; |
438 | m_log.Warn("[SIMIAN ASSET CONNECTOR]: Unexpected response when deleting asset " + url + ": " + | ||
439 | response.StatusCode + " (" + response.StatusDescription + ")"); | ||
440 | } | ||
441 | } | 351 | } |
442 | 352 | ||
443 | return true; | 353 | return true; |
354 | |||
444 | } | 355 | } |
445 | catch (Exception ex) | 356 | catch (Exception ex) |
446 | { | 357 | { |
447 | m_log.Warn("[SIMIAN ASSET CONNECTOR]: Failed to delete asset " + id + " from the asset service: " + ex.Message); | 358 | m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: failed to delete asset {0}; {1}", id, ex.Message); |
448 | return false; | ||
449 | } | 359 | } |
450 | } | ||
451 | 360 | ||
452 | #endregion IAssetService | 361 | return false; |
362 | } | ||
453 | 363 | ||
454 | private AssetBase GetRemote(string id) | 364 | /// <summary> |
365 | /// Invokes the xAddAsset operation on the simian server to create or update an asset | ||
366 | /// </summary> | ||
367 | /// <param name="id"></param> | ||
368 | /// <returns></returns> | ||
369 | private string SimianStoreOperation(AssetBase asset) | ||
455 | { | 370 | { |
456 | AssetBase asset = null; | 371 | try |
457 | Uri url; | 372 | { |
373 | NameValueCollection requestArgs = new NameValueCollection | ||
374 | { | ||
375 | { "RequestMethod", "xAddAsset" }, | ||
376 | { "ContentType", asset.Metadata.ContentType }, | ||
377 | { "EncodedData", Convert.ToBase64String(asset.Data) }, | ||
378 | { "AssetID", asset.FullID.ToString() }, | ||
379 | { "CreatorID", asset.Metadata.CreatorID }, | ||
380 | { "Temporary", asset.Temporary ? "1" : "0" }, | ||
381 | { "Name", asset.Name } | ||
382 | }; | ||
383 | |||
384 | OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs); | ||
385 | if (! response["Success"].AsBoolean()) | ||
386 | { | ||
387 | m_log.WarnFormat("[SIMIAN ASSET CONNECTOR] failed to store asset; {0}",response["Message"].AsString()); | ||
388 | return null; | ||
389 | } | ||
458 | 390 | ||
459 | // Determine if id is an absolute URL or a grid-relative UUID | 391 | // asset.ID is always set before calling this function |
460 | if (!Uri.TryCreate(id, UriKind.Absolute, out url)) | 392 | return asset.ID; |
461 | url = new Uri(m_serverUrl + id); | 393 | |
394 | } | ||
395 | catch (Exception ex) | ||
396 | { | ||
397 | m_log.ErrorFormat("[SIMIAN ASSET CONNECTOR] failed to store asset; {0}",ex.Message); | ||
398 | } | ||
399 | |||
400 | return null; | ||
401 | } | ||
462 | 402 | ||
463 | try | 403 | /// <summary> |
404 | /// Invokes the xGetAsset operation on the simian server to get data associated with an asset | ||
405 | /// </summary> | ||
406 | /// <param name="id"></param> | ||
407 | /// <returns></returns> | ||
408 | private AssetBase SimianGetOperation(string id) | ||
409 | { | ||
410 | try | ||
464 | { | 411 | { |
465 | HttpWebRequest request = UntrustedHttpWebRequest.Create(url); | 412 | NameValueCollection requestArgs = new NameValueCollection |
413 | { | ||
414 | { "RequestMethod", "xGetAsset" }, | ||
415 | { "ID", id } | ||
416 | }; | ||
466 | 417 | ||
467 | using (WebResponse response = request.GetResponse()) | 418 | OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs); |
419 | if (! response["Success"].AsBoolean()) | ||
468 | { | 420 | { |
469 | using (Stream responseStream = response.GetResponseStream()) | 421 | m_log.WarnFormat("[SIMIAN ASSET CONNECTOR] Failed to get asset; {0}",response["Message"].AsString()); |
470 | { | 422 | return null; |
471 | string creatorID = response.Headers.GetOne("X-Asset-Creator-Id") ?? String.Empty; | ||
472 | |||
473 | // Create the asset object | ||
474 | asset = new AssetBase(id, String.Empty, SLUtil.ContentTypeToSLAssetType(response.ContentType), creatorID); | ||
475 | |||
476 | UUID assetID; | ||
477 | if (UUID.TryParse(id, out assetID)) | ||
478 | asset.FullID = assetID; | ||
479 | |||
480 | // Grab the asset data from the response stream | ||
481 | using (MemoryStream stream = new MemoryStream()) | ||
482 | { | ||
483 | responseStream.CopyStream(stream, Int32.MaxValue); | ||
484 | asset.Data = stream.ToArray(); | ||
485 | } | ||
486 | } | ||
487 | } | 423 | } |
424 | |||
425 | AssetBase asset = new AssetBase(); | ||
488 | 426 | ||
489 | // Cache store | 427 | asset.ID = id; |
490 | if (m_cache != null && asset != null) | 428 | asset.Name = String.Empty; |
491 | m_cache.Cache(asset); | 429 | asset.Metadata.ContentType = response["ContentType"].AsString(); // this will also set the asset Type property |
430 | asset.CreatorID = response["CreatorID"].AsString(); | ||
431 | asset.Data = System.Convert.FromBase64String(response["EncodedData"].AsString()); | ||
432 | asset.Local = false; | ||
433 | asset.Temporary = response["Temporary"]; | ||
492 | 434 | ||
493 | return asset; | 435 | return asset; |
494 | } | 436 | } |
495 | catch (Exception ex) | 437 | catch (Exception ex) |
496 | { | 438 | { |
497 | m_log.Warn("[SIMIAN ASSET CONNECTOR]: Asset GET from " + url + " failed: " + ex.Message); | 439 | m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: failed to retrieve asset {0}; {1}", id, ex.Message); |
498 | return null; | ||
499 | } | 440 | } |
441 | |||
442 | return null; | ||
443 | } | ||
444 | |||
445 | /// <summary> | ||
446 | /// Invokes the xGetAssetMetadata operation on the simian server to retrieve metadata for an asset | ||
447 | /// This operation is generally used to determine if an asset exists in the database | ||
448 | /// </summary> | ||
449 | /// <param name="id"></param> | ||
450 | /// <returns></returns> | ||
451 | private AssetMetadata SimianGetMetadataOperation(string id) | ||
452 | { | ||
453 | try | ||
454 | { | ||
455 | NameValueCollection requestArgs = new NameValueCollection | ||
456 | { | ||
457 | { "RequestMethod", "xGetAssetMetadata" }, | ||
458 | { "ID", id } | ||
459 | }; | ||
460 | |||
461 | OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs); | ||
462 | if (! response["Success"].AsBoolean()) | ||
463 | { | ||
464 | // this is not really an error, this call is used to test existence | ||
465 | // m_log.DebugFormat("[SIMIAN ASSET CONNECTOR] Failed to get asset metadata; {0}",response["Message"].AsString()); | ||
466 | return null; | ||
467 | } | ||
468 | |||
469 | AssetMetadata metadata = new AssetMetadata(); | ||
470 | metadata.ID = id; | ||
471 | metadata.ContentType = response["ContentType"].AsString(); | ||
472 | metadata.CreatorID = response["CreatorID"].AsString(); | ||
473 | metadata.Local = false; | ||
474 | metadata.Temporary = response["Temporary"]; | ||
475 | |||
476 | string lastModifiedStr = response["Last-Modified"].AsString(); | ||
477 | if (! String.IsNullOrEmpty(lastModifiedStr)) | ||
478 | { | ||
479 | DateTime lastModified; | ||
480 | if (DateTime.TryParse(lastModifiedStr, out lastModified)) | ||
481 | metadata.CreationDate = lastModified; | ||
482 | } | ||
483 | |||
484 | return metadata; | ||
485 | } | ||
486 | catch (Exception ex) | ||
487 | { | ||
488 | m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: Failed to get asset metadata; {0}", ex.Message); | ||
489 | } | ||
490 | |||
491 | return null; | ||
500 | } | 492 | } |
493 | #endregion | ||
494 | |||
495 | // private AssetMetadata GetRemoteMetadata(string id) | ||
496 | // { | ||
497 | // Uri url; | ||
498 | // AssetMetadata metadata = null; | ||
499 | |||
500 | // // Determine if id is an absolute URL or a grid-relative UUID | ||
501 | // if (!Uri.TryCreate(id, UriKind.Absolute, out url)) | ||
502 | // url = new Uri(m_serverUrl + id); | ||
503 | |||
504 | // try | ||
505 | // { | ||
506 | // HttpWebRequest request = UntrustedHttpWebRequest.Create(url); | ||
507 | // request.Method = "HEAD"; | ||
508 | |||
509 | // using (WebResponse response = request.GetResponse()) | ||
510 | // { | ||
511 | // using (Stream responseStream = response.GetResponseStream()) | ||
512 | // { | ||
513 | // // Create the metadata object | ||
514 | // metadata = new AssetMetadata(); | ||
515 | // metadata.ContentType = response.ContentType; | ||
516 | // metadata.ID = id; | ||
517 | |||
518 | // UUID uuid; | ||
519 | // if (UUID.TryParse(id, out uuid)) | ||
520 | // metadata.FullID = uuid; | ||
521 | |||
522 | // string lastModifiedStr = response.Headers.Get("Last-Modified"); | ||
523 | // if (!String.IsNullOrEmpty(lastModifiedStr)) | ||
524 | // { | ||
525 | // DateTime lastModified; | ||
526 | // if (DateTime.TryParse(lastModifiedStr, out lastModified)) | ||
527 | // metadata.CreationDate = lastModified; | ||
528 | // } | ||
529 | // } | ||
530 | // } | ||
531 | // } | ||
532 | // catch (Exception ex) | ||
533 | // { | ||
534 | // m_log.Warn("[SIMIAN ASSET CONNECTOR]: Asset HEAD from " + url + " failed: " + ex.Message); | ||
535 | // } | ||
536 | |||
537 | // return metadata; | ||
538 | // } | ||
539 | |||
540 | // private AssetBase GetRemote(string id) | ||
541 | // { | ||
542 | // AssetBase asset = null; | ||
543 | // Uri url; | ||
544 | |||
545 | // // Determine if id is an absolute URL or a grid-relative UUID | ||
546 | // if (!Uri.TryCreate(id, UriKind.Absolute, out url)) | ||
547 | // url = new Uri(m_serverUrl + id); | ||
548 | |||
549 | // try | ||
550 | // { | ||
551 | // HttpWebRequest request = UntrustedHttpWebRequest.Create(url); | ||
552 | |||
553 | // using (WebResponse response = request.GetResponse()) | ||
554 | // { | ||
555 | // using (Stream responseStream = response.GetResponseStream()) | ||
556 | // { | ||
557 | // string creatorID = response.Headers.GetOne("X-Asset-Creator-Id") ?? String.Empty; | ||
558 | |||
559 | // // Create the asset object | ||
560 | // asset = new AssetBase(id, String.Empty, SLUtil.ContentTypeToSLAssetType(response.ContentType), creatorID); | ||
561 | |||
562 | // UUID assetID; | ||
563 | // if (UUID.TryParse(id, out assetID)) | ||
564 | // asset.FullID = assetID; | ||
565 | |||
566 | // // Grab the asset data from the response stream | ||
567 | // using (MemoryStream stream = new MemoryStream()) | ||
568 | // { | ||
569 | // responseStream.CopyStream(stream, Int32.MaxValue); | ||
570 | // asset.Data = stream.ToArray(); | ||
571 | // } | ||
572 | // } | ||
573 | // } | ||
574 | |||
575 | // // Cache store | ||
576 | // if (m_cache != null && asset != null) | ||
577 | // m_cache.Cache(asset); | ||
578 | |||
579 | // return asset; | ||
580 | // } | ||
581 | // catch (Exception ex) | ||
582 | // { | ||
583 | // m_log.Warn("[SIMIAN ASSET CONNECTOR]: Asset GET from " + url + " failed: " + ex.Message); | ||
584 | // return null; | ||
585 | // } | ||
586 | // } | ||
587 | |||
588 | // private string StoreRemote(AssetBase asset) | ||
589 | // { | ||
590 | // // Distinguish public and private assets | ||
591 | // bool isPublic = true; | ||
592 | // switch ((AssetType)asset.Type) | ||
593 | // { | ||
594 | // case AssetType.CallingCard: | ||
595 | // case AssetType.Gesture: | ||
596 | // case AssetType.LSLBytecode: | ||
597 | // case AssetType.LSLText: | ||
598 | // isPublic = false; | ||
599 | // break; | ||
600 | // } | ||
601 | |||
602 | // string errorMessage = null; | ||
603 | |||
604 | // // Build the remote storage request | ||
605 | // List<MultipartForm.Element> postParameters = new List<MultipartForm.Element>() | ||
606 | // { | ||
607 | // new MultipartForm.Parameter("AssetID", asset.FullID.ToString()), | ||
608 | // new MultipartForm.Parameter("CreatorID", asset.Metadata.CreatorID), | ||
609 | // new MultipartForm.Parameter("Temporary", asset.Temporary ? "1" : "0"), | ||
610 | // new MultipartForm.Parameter("Public", isPublic ? "1" : "0"), | ||
611 | // new MultipartForm.File("Asset", asset.Name, asset.Metadata.ContentType, asset.Data) | ||
612 | // }; | ||
613 | |||
614 | // // Make the remote storage request | ||
615 | // try | ||
616 | // { | ||
617 | // // Simian does not require the asset ID to be in the URL because it's in the post data. | ||
618 | // // By appending it to the URL also, we allow caching proxies (squid) to invalidate asset URLs | ||
619 | // HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_serverUrl + asset.FullID.ToString()); | ||
620 | |||
621 | // using (HttpWebResponse response = MultipartForm.Post(request, postParameters)) | ||
622 | // { | ||
623 | // using (Stream responseStream = response.GetResponseStream()) | ||
624 | // { | ||
625 | // string responseStr = null; | ||
626 | |||
627 | // try | ||
628 | // { | ||
629 | // responseStr = responseStream.GetStreamString(); | ||
630 | // OSD responseOSD = OSDParser.Deserialize(responseStr); | ||
631 | // if (responseOSD.Type == OSDType.Map) | ||
632 | // { | ||
633 | // OSDMap responseMap = (OSDMap)responseOSD; | ||
634 | // if (responseMap["Success"].AsBoolean()) | ||
635 | // return asset.ID; | ||
636 | // else | ||
637 | // errorMessage = "Upload failed: " + responseMap["Message"].AsString(); | ||
638 | // } | ||
639 | // else | ||
640 | // { | ||
641 | // errorMessage = "Response format was invalid:\n" + responseStr; | ||
642 | // } | ||
643 | // } | ||
644 | // catch (Exception ex) | ||
645 | // { | ||
646 | // if (!String.IsNullOrEmpty(responseStr)) | ||
647 | // errorMessage = "Failed to parse the response:\n" + responseStr; | ||
648 | // else | ||
649 | // errorMessage = "Failed to retrieve the response: " + ex.Message; | ||
650 | // } | ||
651 | // } | ||
652 | // } | ||
653 | // } | ||
654 | // catch (WebException ex) | ||
655 | // { | ||
656 | // errorMessage = ex.Message; | ||
657 | // } | ||
658 | |||
659 | // m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: Failed to store asset \"{0}\" ({1}, {2}): {3}", | ||
660 | // asset.Name, asset.ID, asset.Metadata.ContentType, errorMessage); | ||
661 | |||
662 | // return null; | ||
663 | // } | ||
501 | } | 664 | } |
502 | } | 665 | } |
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs index 03b19ae..c402907 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianAuthenticationServiceConnector.cs | |||
@@ -116,7 +116,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
116 | { "UserID", principalID.ToString() } | 116 | { "UserID", principalID.ToString() } |
117 | }; | 117 | }; |
118 | 118 | ||
119 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 119 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
120 | if (response["Success"].AsBoolean() && response["Identities"] is OSDArray) | 120 | if (response["Success"].AsBoolean() && response["Identities"] is OSDArray) |
121 | { | 121 | { |
122 | bool md5hashFound = false; | 122 | bool md5hashFound = false; |
@@ -159,7 +159,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
159 | { "SessionID", token } | 159 | { "SessionID", token } |
160 | }; | 160 | }; |
161 | 161 | ||
162 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 162 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
163 | if (response["Success"].AsBoolean()) | 163 | if (response["Success"].AsBoolean()) |
164 | { | 164 | { |
165 | return true; | 165 | return true; |
@@ -181,7 +181,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
181 | { "UserID", principalID.ToString() } | 181 | { "UserID", principalID.ToString() } |
182 | }; | 182 | }; |
183 | 183 | ||
184 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 184 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
185 | if (response["Success"].AsBoolean()) | 185 | if (response["Success"].AsBoolean()) |
186 | { | 186 | { |
187 | return true; | 187 | return true; |
@@ -204,7 +204,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
204 | { "UserID", principalID.ToString() } | 204 | { "UserID", principalID.ToString() } |
205 | }; | 205 | }; |
206 | 206 | ||
207 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 207 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
208 | if (response["Success"].AsBoolean() && response["User"] is OSDMap) | 208 | if (response["Success"].AsBoolean() && response["User"] is OSDMap) |
209 | { | 209 | { |
210 | OSDMap userMap = (OSDMap)response["User"]; | 210 | OSDMap userMap = (OSDMap)response["User"]; |
@@ -224,7 +224,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
224 | { "UserID", principalID.ToString() } | 224 | { "UserID", principalID.ToString() } |
225 | }; | 225 | }; |
226 | 226 | ||
227 | response = WebUtil.PostToService(m_serverUrl, requestArgs); | 227 | response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
228 | bool success = response["Success"].AsBoolean(); | 228 | bool success = response["Success"].AsBoolean(); |
229 | 229 | ||
230 | if (!success) | 230 | if (!success) |
@@ -303,7 +303,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
303 | { "UserID", userID.ToString() } | 303 | { "UserID", userID.ToString() } |
304 | }; | 304 | }; |
305 | 305 | ||
306 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 306 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
307 | if (response["Success"].AsBoolean()) | 307 | if (response["Success"].AsBoolean()) |
308 | return response["SessionID"].AsUUID().ToString(); | 308 | return response["SessionID"].AsUUID().ToString(); |
309 | else | 309 | else |
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs index 841bfa0..a397740 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianAvatarServiceConnector.cs | |||
@@ -122,7 +122,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
122 | { "UserID", userID.ToString() } | 122 | { "UserID", userID.ToString() } |
123 | }; | 123 | }; |
124 | 124 | ||
125 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 125 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
126 | if (response["Success"].AsBoolean()) | 126 | if (response["Success"].AsBoolean()) |
127 | { | 127 | { |
128 | OSDMap map = null; | 128 | OSDMap map = null; |
@@ -168,7 +168,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
168 | { "LLPackedAppearance", OSDParser.SerializeJsonString(map) } | 168 | { "LLPackedAppearance", OSDParser.SerializeJsonString(map) } |
169 | }; | 169 | }; |
170 | 170 | ||
171 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 171 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
172 | bool success = response["Success"].AsBoolean(); | 172 | bool success = response["Success"].AsBoolean(); |
173 | 173 | ||
174 | if (! success) | 174 | if (! success) |
@@ -189,7 +189,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
189 | { "UserID", userID.ToString() } | 189 | { "UserID", userID.ToString() } |
190 | }; | 190 | }; |
191 | 191 | ||
192 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 192 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
193 | if (response["Success"].AsBoolean()) | 193 | if (response["Success"].AsBoolean()) |
194 | { | 194 | { |
195 | OSDMap map = null; | 195 | OSDMap map = null; |
@@ -306,7 +306,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
306 | { "LLAttachments", OSDParser.SerializeJsonString(items) } | 306 | { "LLAttachments", OSDParser.SerializeJsonString(items) } |
307 | }; | 307 | }; |
308 | 308 | ||
309 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 309 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
310 | bool success = response["Success"].AsBoolean(); | 310 | bool success = response["Success"].AsBoolean(); |
311 | 311 | ||
312 | if (!success) | 312 | if (!success) |
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianExternalCapsModule.cs b/OpenSim/Services/Connectors/SimianGrid/SimianExternalCapsModule.cs new file mode 100644 index 0000000..764e71f --- /dev/null +++ b/OpenSim/Services/Connectors/SimianGrid/SimianExternalCapsModule.cs | |||
@@ -0,0 +1,180 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Reflection; | ||
32 | using System.IO; | ||
33 | using System.Web; | ||
34 | |||
35 | using log4net; | ||
36 | using Nini.Config; | ||
37 | using Mono.Addins; | ||
38 | |||
39 | using OpenMetaverse; | ||
40 | using OpenMetaverse.StructuredData; | ||
41 | |||
42 | using OpenSim.Framework; | ||
43 | using OpenSim.Region.Framework.Interfaces; | ||
44 | using OpenSim.Region.Framework.Scenes; | ||
45 | using OpenSim.Services.Interfaces; | ||
46 | using Caps = OpenSim.Framework.Capabilities.Caps; | ||
47 | |||
48 | namespace OpenSim.Services.Connectors.SimianGrid | ||
49 | { | ||
50 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimianExternalCapsModule")] | ||
51 | public class SimianExternalCapsModule : INonSharedRegionModule, IExternalCapsModule | ||
52 | { | ||
53 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
54 | |||
55 | private bool m_enabled = true; | ||
56 | private Scene m_scene; | ||
57 | private String m_simianURL; | ||
58 | |||
59 | #region IRegionModule Members | ||
60 | |||
61 | public string Name | ||
62 | { | ||
63 | get { return this.GetType().Name; } | ||
64 | } | ||
65 | |||
66 | public void Initialise(IConfigSource config) | ||
67 | { | ||
68 | try | ||
69 | { | ||
70 | IConfig m_config; | ||
71 | |||
72 | if ((m_config = config.Configs["SimianExternalCaps"]) != null) | ||
73 | { | ||
74 | m_enabled = m_config.GetBoolean("Enabled", m_enabled); | ||
75 | if ((m_config = config.Configs["SimianGrid"]) != null) | ||
76 | { | ||
77 | m_simianURL = m_config.GetString("SimianServiceURL"); | ||
78 | if (String.IsNullOrEmpty(m_simianURL)) | ||
79 | { | ||
80 | //m_log.DebugFormat("[SimianGrid] service URL is not defined"); | ||
81 | m_enabled = false; | ||
82 | return; | ||
83 | } | ||
84 | } | ||
85 | } | ||
86 | else | ||
87 | m_enabled = false; | ||
88 | } | ||
89 | catch (Exception e) | ||
90 | { | ||
91 | m_log.ErrorFormat("[SimianExternalCaps] initialization error: {0}",e.Message); | ||
92 | return; | ||
93 | } | ||
94 | } | ||
95 | |||
96 | public void PostInitialise() { } | ||
97 | public void Close() { } | ||
98 | |||
99 | public void AddRegion(Scene scene) | ||
100 | { | ||
101 | if (! m_enabled) | ||
102 | return; | ||
103 | |||
104 | m_scene = scene; | ||
105 | m_scene.RegisterModuleInterface<IExternalCapsModule>(this); | ||
106 | } | ||
107 | |||
108 | public void RemoveRegion(Scene scene) | ||
109 | { | ||
110 | if (! m_enabled) | ||
111 | return; | ||
112 | |||
113 | m_scene.EventManager.OnRegisterCaps -= RegisterCapsEventHandler; | ||
114 | m_scene.EventManager.OnDeregisterCaps -= DeregisterCapsEventHandler; | ||
115 | } | ||
116 | |||
117 | public void RegionLoaded(Scene scene) | ||
118 | { | ||
119 | if (! m_enabled) | ||
120 | return; | ||
121 | |||
122 | m_scene.EventManager.OnRegisterCaps += RegisterCapsEventHandler; | ||
123 | m_scene.EventManager.OnDeregisterCaps += DeregisterCapsEventHandler; | ||
124 | } | ||
125 | |||
126 | public Type ReplaceableInterface | ||
127 | { | ||
128 | get { return null; } | ||
129 | } | ||
130 | |||
131 | #endregion | ||
132 | |||
133 | #region IExternalCapsModule | ||
134 | // Eg http://grid.sciencesim.com/GridPublic/%CAP%/%OP%/" | ||
135 | public bool RegisterExternalUserCapsHandler(UUID agentID, Caps caps, String capName, String urlSkel) | ||
136 | { | ||
137 | UUID cap = UUID.Random(); | ||
138 | |||
139 | // Call to simian to register the cap we generated | ||
140 | // NameValueCollection requestArgs = new NameValueCollection | ||
141 | // { | ||
142 | // { "RequestMethod", "AddCapability" }, | ||
143 | // { "Resource", "user" }, | ||
144 | // { "Expiration", 0 }, | ||
145 | // { "OwnerID", agentID.ToString() }, | ||
146 | // { "CapabilityID", cap.ToString() } | ||
147 | // }; | ||
148 | |||
149 | // OSDMap response = SimianGrid.PostToService(m_simianURL, requestArgs); | ||
150 | |||
151 | Dictionary<String,String> subs = new Dictionary<String,String>(); | ||
152 | subs["%OP%"] = capName; | ||
153 | subs["%USR%"] = agentID.ToString(); | ||
154 | subs["%CAP%"] = cap.ToString(); | ||
155 | subs["%SIM%"] = m_scene.RegionInfo.RegionID.ToString(); | ||
156 | |||
157 | caps.RegisterHandler(capName,ExpandSkeletonURL(urlSkel,subs)); | ||
158 | return true; | ||
159 | } | ||
160 | |||
161 | #endregion | ||
162 | |||
163 | #region EventHandlers | ||
164 | public void RegisterCapsEventHandler(UUID agentID, Caps caps) { } | ||
165 | public void DeregisterCapsEventHandler(UUID agentID, Caps caps) { } | ||
166 | #endregion | ||
167 | |||
168 | private String ExpandSkeletonURL(String urlSkel, Dictionary<String,String> subs) | ||
169 | { | ||
170 | String result = urlSkel; | ||
171 | |||
172 | foreach (KeyValuePair<String,String> kvp in subs) | ||
173 | { | ||
174 | result = result.Replace(kvp.Key,kvp.Value); | ||
175 | } | ||
176 | |||
177 | return result; | ||
178 | } | ||
179 | } | ||
180 | } \ No newline at end of file | ||
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs index 7422d94..9a8164c 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianFriendsServiceConnector.cs | |||
@@ -153,7 +153,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
153 | { "Value", flags.ToString() } | 153 | { "Value", flags.ToString() } |
154 | }; | 154 | }; |
155 | 155 | ||
156 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 156 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
157 | bool success = response["Success"].AsBoolean(); | 157 | bool success = response["Success"].AsBoolean(); |
158 | 158 | ||
159 | if (!success) | 159 | if (!success) |
@@ -180,7 +180,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
180 | { "Key", friend } | 180 | { "Key", friend } |
181 | }; | 181 | }; |
182 | 182 | ||
183 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 183 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
184 | bool success = response["Success"].AsBoolean(); | 184 | bool success = response["Success"].AsBoolean(); |
185 | 185 | ||
186 | if (!success) | 186 | if (!success) |
@@ -200,7 +200,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
200 | { "Type", "Friend" } | 200 | { "Type", "Friend" } |
201 | }; | 201 | }; |
202 | 202 | ||
203 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 203 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
204 | if (response["Success"].AsBoolean() && response["Entries"] is OSDArray) | 204 | if (response["Success"].AsBoolean() && response["Entries"] is OSDArray) |
205 | { | 205 | { |
206 | return (OSDArray)response["Entries"]; | 206 | return (OSDArray)response["Entries"]; |
@@ -221,7 +221,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
221 | { "Type", "Friend" } | 221 | { "Type", "Friend" } |
222 | }; | 222 | }; |
223 | 223 | ||
224 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 224 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
225 | if (response["Success"].AsBoolean() && response["Entries"] is OSDArray) | 225 | if (response["Success"].AsBoolean() && response["Entries"] is OSDArray) |
226 | { | 226 | { |
227 | return (OSDArray)response["Entries"]; | 227 | return (OSDArray)response["Entries"]; |
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs index 847319c..9898da9 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianGrid.cs | |||
@@ -26,8 +26,122 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
30 | using System.Collections.Specialized; | ||
31 | using System.Reflection; | ||
32 | using log4net; | ||
29 | using Mono.Addins; | 33 | using Mono.Addins; |
30 | using Nini.Config; | 34 | using Nini.Config; |
35 | using OpenSim.Framework; | ||
36 | using OpenSim.Region.Framework.Interfaces; | ||
37 | using OpenSim.Region.Framework.Scenes; | ||
38 | using OpenSim.Services.Interfaces; | ||
39 | using OpenMetaverse; | ||
40 | using OpenMetaverse.StructuredData; | ||
31 | 41 | ||
32 | [assembly: Addin("SimianGrid", "1.0")] | 42 | [assembly: Addin("SimianGrid", "1.0")] |
33 | [assembly: AddinDependency("OpenSim", "0.5")] | 43 | [assembly: AddinDependency("OpenSim", "0.5")] |
44 | |||
45 | namespace OpenSim.Services.Connectors.SimianGrid | ||
46 | { | ||
47 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimianExternalCapsModule")] | ||
48 | public class SimianGrid : ISharedRegionModule | ||
49 | { | ||
50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
51 | |||
52 | private IConfig m_config = null; | ||
53 | |||
54 | private String m_simianURL; | ||
55 | |||
56 | #region IRegionModule Members | ||
57 | |||
58 | public string Name | ||
59 | { | ||
60 | get { return this.GetType().Name; } | ||
61 | } | ||
62 | |||
63 | public void Initialise(IConfigSource config) | ||
64 | { | ||
65 | try | ||
66 | { | ||
67 | m_config = config.Configs["SimianGrid"]; | ||
68 | |||
69 | if (m_config != null) | ||
70 | { | ||
71 | m_simianURL = m_config.GetString("SimianServiceURL"); | ||
72 | if (String.IsNullOrEmpty(m_simianURL)) | ||
73 | { | ||
74 | // m_log.DebugFormat("[SimianGrid] service URL is not defined"); | ||
75 | return; | ||
76 | } | ||
77 | |||
78 | InitialiseSimCap(); | ||
79 | SimulatorCapability = SimulatorCapability.Trim(); | ||
80 | m_log.InfoFormat("[SimianExternalCaps] using {0} as simulator capability",SimulatorCapability); | ||
81 | } | ||
82 | } | ||
83 | catch (Exception e) | ||
84 | { | ||
85 | m_log.ErrorFormat("[SimianExternalCaps] initialization error: {0}",e.Message); | ||
86 | return; | ||
87 | } | ||
88 | } | ||
89 | |||
90 | public void PostInitialise() { } | ||
91 | public void Close() { } | ||
92 | public void AddRegion(Scene scene) { } | ||
93 | public void RemoveRegion(Scene scene) { } | ||
94 | public void RegionLoaded(Scene scene) { } | ||
95 | |||
96 | public Type ReplaceableInterface | ||
97 | { | ||
98 | get { return null; } | ||
99 | } | ||
100 | |||
101 | ///<summary> | ||
102 | /// Try a variety of methods for finding the simian simulator capability; first check the | ||
103 | /// configuration itself, then look for a file that contains the cap, then finally look | ||
104 | /// for an environment variable that contains it. | ||
105 | ///</summary> | ||
106 | private void InitialiseSimCap() | ||
107 | { | ||
108 | if (m_config.Contains("SimulatorCapability")) | ||
109 | { | ||
110 | SimulatorCapability = m_config.GetString("SimulatorCapability"); | ||
111 | return; | ||
112 | } | ||
113 | |||
114 | if (m_config.Contains("SimulatorCapabilityFile")) | ||
115 | { | ||
116 | String filename = m_config.GetString("SimulatorCapabilityFile"); | ||
117 | if (System.IO.File.Exists(filename)) | ||
118 | { | ||
119 | SimulatorCapability = System.IO.File.ReadAllText(filename); | ||
120 | return; | ||
121 | } | ||
122 | } | ||
123 | |||
124 | if (m_config.Contains("SimulatorCapabilityVariable")) | ||
125 | { | ||
126 | String envname = m_config.GetString("SimulatorCapabilityVariable"); | ||
127 | String envvalue = System.Environment.GetEnvironmentVariable(envname); | ||
128 | if (envvalue != null) | ||
129 | { | ||
130 | SimulatorCapability = envvalue; | ||
131 | return; | ||
132 | } | ||
133 | } | ||
134 | |||
135 | m_log.WarnFormat("[SimianExternalCaps] no method specified for simulator capability"); | ||
136 | } | ||
137 | |||
138 | #endregion | ||
139 | |||
140 | public static String SimulatorCapability = UUID.Zero.ToString(); | ||
141 | public static OSDMap PostToService(string url, NameValueCollection data) | ||
142 | { | ||
143 | data["cap"] = SimulatorCapability; | ||
144 | return WebUtil.PostToService(url, data); | ||
145 | } | ||
146 | } | ||
147 | } \ No newline at end of file | ||
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs index 93fdae3..b999509 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Collections.Specialized; | ||
30 | using System.Reflection; | 31 | using System.Reflection; |
31 | using System.Net; | 32 | using System.Net; |
32 | using System.IO; | 33 | using System.IO; |
@@ -43,7 +44,8 @@ using OpenSim.Region.Framework.Scenes; | |||
43 | using OpenMetaverse; | 44 | using OpenMetaverse; |
44 | using OpenMetaverse.StructuredData; | 45 | using OpenMetaverse.StructuredData; |
45 | 46 | ||
46 | namespace OpenSim.Region.OptionalModules.Simian | 47 | //namespace OpenSim.Region.OptionalModules.Simian |
48 | namespace OpenSim.Services.Connectors.SimianGrid | ||
47 | { | 49 | { |
48 | /// <summary> | 50 | /// <summary> |
49 | /// </summary> | 51 | /// </summary> |
@@ -196,67 +198,84 @@ namespace OpenSim.Region.OptionalModules.Simian | |||
196 | } | 198 | } |
197 | } | 199 | } |
198 | 200 | ||
199 | List<MultipartForm.Element> postParameters = new List<MultipartForm.Element>() | 201 | NameValueCollection requestArgs = new NameValueCollection |
202 | { | ||
203 | { "RequestMethod", "xAddMapTile" }, | ||
204 | { "X", scene.RegionInfo.RegionLocX.ToString() }, | ||
205 | { "Y", scene.RegionInfo.RegionLocY.ToString() }, | ||
206 | { "ContentType", "image/png" }, | ||
207 | { "EncodedData", System.Convert.ToBase64String(pngData) } | ||
208 | }; | ||
209 | |||
210 | OSDMap response = SimianGrid.PostToService(m_serverUrl,requestArgs); | ||
211 | if (! response["Success"].AsBoolean()) | ||
200 | { | 212 | { |
201 | new MultipartForm.Parameter("X", scene.RegionInfo.RegionLocX.ToString()), | 213 | m_log.WarnFormat("[SIMIAN MAPTILE] failed to store map tile; {0}",response["Message"].AsString()); |
202 | new MultipartForm.Parameter("Y", scene.RegionInfo.RegionLocY.ToString()), | 214 | return; |
203 | new MultipartForm.File("Tile", "tile.png", "image/png", pngData) | 215 | } |
204 | }; | ||
205 | 216 | ||
206 | string errorMessage = null; | 217 | // List<MultipartForm.Element> postParameters = new List<MultipartForm.Element>() |
207 | int tickstart = Util.EnvironmentTickCount(); | 218 | // { |
219 | // new MultipartForm.Parameter("X", scene.RegionInfo.RegionLocX.ToString()), | ||
220 | // new MultipartForm.Parameter("Y", scene.RegionInfo.RegionLocY.ToString()), | ||
221 | // new MultipartForm.File("Tile", "tile.png", "image/png", pngData) | ||
222 | // }; | ||
208 | 223 | ||
209 | // Make the remote storage request | 224 | // string errorMessage = null; |
210 | try | 225 | // int tickstart = Util.EnvironmentTickCount(); |
211 | { | ||
212 | HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_serverUrl); | ||
213 | request.Timeout = 20000; | ||
214 | request.ReadWriteTimeout = 5000; | ||
215 | 226 | ||
216 | using (HttpWebResponse response = MultipartForm.Post(request, postParameters)) | 227 | // // Make the remote storage request |
217 | { | 228 | // try |
218 | using (Stream responseStream = response.GetResponseStream()) | 229 | // { |
219 | { | 230 | // HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_serverUrl); |
220 | string responseStr = responseStream.GetStreamString(); | 231 | // request.Timeout = 20000; |
221 | OSD responseOSD = OSDParser.Deserialize(responseStr); | 232 | // request.ReadWriteTimeout = 5000; |
222 | if (responseOSD.Type == OSDType.Map) | ||
223 | { | ||
224 | OSDMap responseMap = (OSDMap)responseOSD; | ||
225 | if (responseMap["Success"].AsBoolean()) | ||
226 | return; | ||
227 | 233 | ||
228 | errorMessage = "Upload failed: " + responseMap["Message"].AsString(); | 234 | // using (HttpWebResponse response = MultipartForm.Post(request, postParameters)) |
229 | } | 235 | // { |
230 | else | 236 | // using (Stream responseStream = response.GetResponseStream()) |
231 | { | 237 | // { |
232 | errorMessage = "Response format was invalid:\n" + responseStr; | 238 | // string responseStr = responseStream.GetStreamString(); |
233 | } | 239 | // OSD responseOSD = OSDParser.Deserialize(responseStr); |
234 | } | 240 | // if (responseOSD.Type == OSDType.Map) |
235 | } | 241 | // { |
236 | } | 242 | // OSDMap responseMap = (OSDMap)responseOSD; |
237 | catch (WebException we) | 243 | // if (responseMap["Success"].AsBoolean()) |
238 | { | 244 | // return; |
239 | errorMessage = we.Message; | 245 | |
240 | if (we.Status == WebExceptionStatus.ProtocolError) | 246 | // errorMessage = "Upload failed: " + responseMap["Message"].AsString(); |
241 | { | 247 | // } |
242 | HttpWebResponse webResponse = (HttpWebResponse)we.Response; | 248 | // else |
243 | errorMessage = String.Format("[{0}] {1}", | 249 | // { |
244 | webResponse.StatusCode,webResponse.StatusDescription); | 250 | // errorMessage = "Response format was invalid:\n" + responseStr; |
245 | } | 251 | // } |
246 | } | 252 | // } |
247 | catch (Exception ex) | 253 | // } |
248 | { | 254 | // } |
249 | errorMessage = ex.Message; | 255 | // catch (WebException we) |
250 | } | 256 | // { |
251 | finally | 257 | // errorMessage = we.Message; |
252 | { | 258 | // if (we.Status == WebExceptionStatus.ProtocolError) |
253 | // This just dumps a warning for any operation that takes more than 100 ms | 259 | // { |
254 | int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); | 260 | // HttpWebResponse webResponse = (HttpWebResponse)we.Response; |
255 | m_log.DebugFormat("[SIMIAN MAPTILE]: map tile uploaded in {0}ms",tickdiff); | 261 | // errorMessage = String.Format("[{0}] {1}", |
256 | } | 262 | // webResponse.StatusCode,webResponse.StatusDescription); |
263 | // } | ||
264 | // } | ||
265 | // catch (Exception ex) | ||
266 | // { | ||
267 | // errorMessage = ex.Message; | ||
268 | // } | ||
269 | // finally | ||
270 | // { | ||
271 | // // This just dumps a warning for any operation that takes more than 100 ms | ||
272 | // int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); | ||
273 | // m_log.DebugFormat("[SIMIAN MAPTILE]: map tile uploaded in {0}ms",tickdiff); | ||
274 | // } | ||
275 | |||
276 | // m_log.WarnFormat("[SIMIAN MAPTILE]: Failed to store {0} byte tile for {1}: {2}", | ||
277 | // pngData.Length, scene.RegionInfo.RegionName, errorMessage); | ||
257 | 278 | ||
258 | m_log.WarnFormat("[SIMIAN MAPTILE]: Failed to store {0} byte tile for {1}: {2}", | ||
259 | pngData.Length, scene.RegionInfo.RegionName, errorMessage); | ||
260 | } | 279 | } |
261 | } | 280 | } |
262 | } \ No newline at end of file | 281 | } \ No newline at end of file |
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs index 20eaa3a..36a5182 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianGridServiceConnector.cs | |||
@@ -140,7 +140,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
140 | { "ExtraData", OSDParser.SerializeJsonString(extraData) } | 140 | { "ExtraData", OSDParser.SerializeJsonString(extraData) } |
141 | }; | 141 | }; |
142 | 142 | ||
143 | OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); | 143 | OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs); |
144 | if (response["Success"].AsBoolean()) | 144 | if (response["Success"].AsBoolean()) |
145 | return String.Empty; | 145 | return String.Empty; |
146 | else | 146 | else |
@@ -156,7 +156,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
156 | { "Enabled", "0" } | 156 | { "Enabled", "0" } |
157 | }; | 157 | }; |
158 | 158 | ||
159 | OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); | 159 | OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs); |
160 | bool success = response["Success"].AsBoolean(); | 160 | bool success = response["Success"].AsBoolean(); |
161 | 161 | ||
162 | if (!success) | 162 | if (!success) |
@@ -203,7 +203,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
203 | 203 | ||
204 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request region with uuid {0}",regionID.ToString()); | 204 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request region with uuid {0}",regionID.ToString()); |
205 | 205 | ||
206 | OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); | 206 | OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs); |
207 | if (response["Success"].AsBoolean()) | 207 | if (response["Success"].AsBoolean()) |
208 | { | 208 | { |
209 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] uuid request successful {0}",response["Name"].AsString()); | 209 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] uuid request successful {0}",response["Name"].AsString()); |
@@ -231,7 +231,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
231 | 231 | ||
232 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request grid at {0}",position.ToString()); | 232 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request grid at {0}",position.ToString()); |
233 | 233 | ||
234 | OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); | 234 | OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs); |
235 | if (response["Success"].AsBoolean()) | 235 | if (response["Success"].AsBoolean()) |
236 | { | 236 | { |
237 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] position request successful {0}",response["Name"].AsString()); | 237 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] position request successful {0}",response["Name"].AsString()); |
@@ -272,7 +272,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
272 | 272 | ||
273 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request regions with name {0}",name); | 273 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request regions with name {0}",name); |
274 | 274 | ||
275 | OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); | 275 | OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs); |
276 | if (response["Success"].AsBoolean()) | 276 | if (response["Success"].AsBoolean()) |
277 | { | 277 | { |
278 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] found regions with name {0}",name); | 278 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] found regions with name {0}",name); |
@@ -310,7 +310,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
310 | //m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request regions by range {0} to {1}",minPosition.ToString(),maxPosition.ToString()); | 310 | //m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request regions by range {0} to {1}",minPosition.ToString(),maxPosition.ToString()); |
311 | 311 | ||
312 | 312 | ||
313 | OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); | 313 | OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs); |
314 | if (response["Success"].AsBoolean()) | 314 | if (response["Success"].AsBoolean()) |
315 | { | 315 | { |
316 | OSDArray array = response["Scenes"] as OSDArray; | 316 | OSDArray array = response["Scenes"] as OSDArray; |
@@ -341,6 +341,12 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
341 | return new List<GridRegion>(0); | 341 | return new List<GridRegion>(0); |
342 | } | 342 | } |
343 | 343 | ||
344 | public List<GridRegion> GetDefaultHypergridRegions(UUID scopeID) | ||
345 | { | ||
346 | // TODO: Allow specifying the default grid location | ||
347 | return GetDefaultRegions(scopeID); | ||
348 | } | ||
349 | |||
344 | public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y) | 350 | public List<GridRegion> GetFallbackRegions(UUID scopeID, int x, int y) |
345 | { | 351 | { |
346 | GridRegion defRegion = GetNearestRegion(new Vector3d(x, y, 0.0), true); | 352 | GridRegion defRegion = GetNearestRegion(new Vector3d(x, y, 0.0), true); |
@@ -361,7 +367,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
361 | { "Enabled", "1" } | 367 | { "Enabled", "1" } |
362 | }; | 368 | }; |
363 | 369 | ||
364 | OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); | 370 | OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs); |
365 | if (response["Success"].AsBoolean()) | 371 | if (response["Success"].AsBoolean()) |
366 | { | 372 | { |
367 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] found regions with name {0}",name); | 373 | // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] found regions with name {0}",name); |
@@ -391,7 +397,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
391 | 397 | ||
392 | m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request region flags for {0}",regionID.ToString()); | 398 | m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request region flags for {0}",regionID.ToString()); |
393 | 399 | ||
394 | OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); | 400 | OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs); |
395 | if (response["Success"].AsBoolean()) | 401 | if (response["Success"].AsBoolean()) |
396 | { | 402 | { |
397 | OSDMap extraData = response["ExtraData"] as OSDMap; | 403 | OSDMap extraData = response["ExtraData"] as OSDMap; |
@@ -498,7 +504,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
498 | if (onlyEnabled) | 504 | if (onlyEnabled) |
499 | requestArgs["Enabled"] = "1"; | 505 | requestArgs["Enabled"] = "1"; |
500 | 506 | ||
501 | OSDMap response = WebUtil.PostToService(m_ServerURI, requestArgs); | 507 | OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs); |
502 | if (response["Success"].AsBoolean()) | 508 | if (response["Success"].AsBoolean()) |
503 | { | 509 | { |
504 | return ResponseToGridRegion(response); | 510 | return ResponseToGridRegion(response); |
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs index 36325ce..97eaabe 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs | |||
@@ -156,7 +156,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
156 | { "OwnerID", userID.ToString() } | 156 | { "OwnerID", userID.ToString() } |
157 | }; | 157 | }; |
158 | 158 | ||
159 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 159 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
160 | bool success = response["Success"].AsBoolean(); | 160 | bool success = response["Success"].AsBoolean(); |
161 | 161 | ||
162 | if (!success) | 162 | if (!success) |
@@ -182,7 +182,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
182 | { "ChildrenOnly", "0" } | 182 | { "ChildrenOnly", "0" } |
183 | }; | 183 | }; |
184 | 184 | ||
185 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 185 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
186 | if (response["Success"].AsBoolean() && response["Items"] is OSDArray) | 186 | if (response["Success"].AsBoolean() && response["Items"] is OSDArray) |
187 | { | 187 | { |
188 | OSDArray items = (OSDArray)response["Items"]; | 188 | OSDArray items = (OSDArray)response["Items"]; |
@@ -244,7 +244,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
244 | { "ChildrenOnly", "1" } | 244 | { "ChildrenOnly", "1" } |
245 | }; | 245 | }; |
246 | 246 | ||
247 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 247 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
248 | if (response["Success"].AsBoolean() && response["Items"] is OSDArray) | 248 | if (response["Success"].AsBoolean() && response["Items"] is OSDArray) |
249 | { | 249 | { |
250 | OSDArray items = (OSDArray)response["Items"]; | 250 | OSDArray items = (OSDArray)response["Items"]; |
@@ -274,7 +274,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
274 | { "OwnerID", userID.ToString() } | 274 | { "OwnerID", userID.ToString() } |
275 | }; | 275 | }; |
276 | 276 | ||
277 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 277 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
278 | if (response["Success"].AsBoolean() && response["Folder"] is OSDMap) | 278 | if (response["Success"].AsBoolean() && response["Folder"] is OSDMap) |
279 | { | 279 | { |
280 | OSDMap folder = (OSDMap)response["Folder"]; | 280 | OSDMap folder = (OSDMap)response["Folder"]; |
@@ -312,7 +312,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
312 | { "ChildrenOnly", "1" } | 312 | { "ChildrenOnly", "1" } |
313 | }; | 313 | }; |
314 | 314 | ||
315 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 315 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
316 | if (response["Success"].AsBoolean() && response["Items"] is OSDArray) | 316 | if (response["Success"].AsBoolean() && response["Items"] is OSDArray) |
317 | { | 317 | { |
318 | List<InventoryItemBase> items = GetItemsFromResponse((OSDArray)response["Items"]); | 318 | List<InventoryItemBase> items = GetItemsFromResponse((OSDArray)response["Items"]); |
@@ -349,7 +349,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
349 | { "ChildrenOnly", "1" } | 349 | { "ChildrenOnly", "1" } |
350 | }; | 350 | }; |
351 | 351 | ||
352 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 352 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
353 | if (response["Success"].AsBoolean() && response["Items"] is OSDArray) | 353 | if (response["Success"].AsBoolean() && response["Items"] is OSDArray) |
354 | { | 354 | { |
355 | OSDArray items = (OSDArray)response["Items"]; | 355 | OSDArray items = (OSDArray)response["Items"]; |
@@ -383,7 +383,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
383 | { "ChildrenOnly", "1" } | 383 | { "ChildrenOnly", "1" } |
384 | }; | 384 | }; |
385 | 385 | ||
386 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 386 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
387 | if (response["Success"].AsBoolean() && response["Items"] is OSDArray) | 387 | if (response["Success"].AsBoolean() && response["Items"] is OSDArray) |
388 | { | 388 | { |
389 | OSDArray items = (OSDArray)response["Items"]; | 389 | OSDArray items = (OSDArray)response["Items"]; |
@@ -423,7 +423,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
423 | { "ChildrenOnly", "1" } | 423 | { "ChildrenOnly", "1" } |
424 | }; | 424 | }; |
425 | 425 | ||
426 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 426 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
427 | if (response["Success"].AsBoolean() && response["Items"] is OSDArray) | 427 | if (response["Success"].AsBoolean() && response["Items"] is OSDArray) |
428 | { | 428 | { |
429 | OSDArray items = (OSDArray)response["Items"]; | 429 | OSDArray items = (OSDArray)response["Items"]; |
@@ -454,7 +454,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
454 | { "ContentType", SLUtil.SLAssetTypeToContentType(folder.Type) } | 454 | { "ContentType", SLUtil.SLAssetTypeToContentType(folder.Type) } |
455 | }; | 455 | }; |
456 | 456 | ||
457 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 457 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
458 | bool success = response["Success"].AsBoolean(); | 458 | bool success = response["Success"].AsBoolean(); |
459 | 459 | ||
460 | if (!success) | 460 | if (!success) |
@@ -518,7 +518,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
518 | { "ItemID", itemID.ToString() } | 518 | { "ItemID", itemID.ToString() } |
519 | }; | 519 | }; |
520 | 520 | ||
521 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 521 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
522 | bool success = response["Success"].AsBoolean(); | 522 | bool success = response["Success"].AsBoolean(); |
523 | 523 | ||
524 | if (!success) | 524 | if (!success) |
@@ -546,7 +546,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
546 | { "FolderID", folder.ID.ToString() } | 546 | { "FolderID", folder.ID.ToString() } |
547 | }; | 547 | }; |
548 | 548 | ||
549 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 549 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
550 | bool success = response["Success"].AsBoolean(); | 550 | bool success = response["Success"].AsBoolean(); |
551 | 551 | ||
552 | if (!success) | 552 | if (!success) |
@@ -623,7 +623,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
623 | { "ExtraData", OSDParser.SerializeJsonString(extraData) } | 623 | { "ExtraData", OSDParser.SerializeJsonString(extraData) } |
624 | }; | 624 | }; |
625 | 625 | ||
626 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 626 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
627 | bool success = response["Success"].AsBoolean(); | 627 | bool success = response["Success"].AsBoolean(); |
628 | 628 | ||
629 | if (!success) | 629 | if (!success) |
@@ -847,7 +847,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
847 | { "Items", String.Join(",", itemIDs) } | 847 | { "Items", String.Join(",", itemIDs) } |
848 | }; | 848 | }; |
849 | 849 | ||
850 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 850 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
851 | bool success = response["Success"].AsBoolean(); | 851 | bool success = response["Success"].AsBoolean(); |
852 | 852 | ||
853 | if (!success) | 853 | if (!success) |
@@ -885,7 +885,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
885 | { "UserID", userID.ToString() } | 885 | { "UserID", userID.ToString() } |
886 | }; | 886 | }; |
887 | 887 | ||
888 | OSDMap response = WebUtil.PostToService(m_userServerUrl, requestArgs); | 888 | OSDMap response = SimianGrid.PostToService(m_userServerUrl, requestArgs); |
889 | if (response["Success"].AsBoolean()) | 889 | if (response["Success"].AsBoolean()) |
890 | { | 890 | { |
891 | OSDMap user = response["User"] as OSDMap; | 891 | OSDMap user = response["User"] as OSDMap; |
@@ -916,7 +916,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
916 | { "Gestures", OSDParser.SerializeJsonString(gestures) } | 916 | { "Gestures", OSDParser.SerializeJsonString(gestures) } |
917 | }; | 917 | }; |
918 | 918 | ||
919 | OSDMap response = WebUtil.PostToService(m_userServerUrl, requestArgs); | 919 | OSDMap response = SimianGrid.PostToService(m_userServerUrl, requestArgs); |
920 | if (!response["Success"].AsBoolean()) | 920 | if (!response["Success"].AsBoolean()) |
921 | { | 921 | { |
922 | m_log.Warn("[SIMIAN INVENTORY CONNECTOR]: Failed to save active gestures for " + userID + ": " + | 922 | m_log.Warn("[SIMIAN INVENTORY CONNECTOR]: Failed to save active gestures for " + userID + ": " + |
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs index 854bea4..211b775 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs | |||
@@ -65,7 +65,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
65 | public void PostInitialise() { } | 65 | public void PostInitialise() { } |
66 | public void Close() { } | 66 | public void Close() { } |
67 | 67 | ||
68 | public SimianPresenceServiceConnector() { m_activityDetector = new SimianActivityDetector(this); } | 68 | public SimianPresenceServiceConnector() { } |
69 | public string Name { get { return "SimianPresenceServiceConnector"; } } | 69 | public string Name { get { return "SimianPresenceServiceConnector"; } } |
70 | public void AddRegion(Scene scene) | 70 | public void AddRegion(Scene scene) |
71 | { | 71 | { |
@@ -121,6 +121,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
121 | if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("=")) | 121 | if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("=")) |
122 | serviceUrl = serviceUrl + '/'; | 122 | serviceUrl = serviceUrl + '/'; |
123 | m_serverUrl = serviceUrl; | 123 | m_serverUrl = serviceUrl; |
124 | m_activityDetector = new SimianActivityDetector(this); | ||
124 | m_Enabled = true; | 125 | m_Enabled = true; |
125 | } | 126 | } |
126 | } | 127 | } |
@@ -137,17 +138,18 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
137 | userID, sessionID, secureSessionID); | 138 | userID, sessionID, secureSessionID); |
138 | 139 | ||
139 | NameValueCollection requestArgs = new NameValueCollection | 140 | NameValueCollection requestArgs = new NameValueCollection |
140 | { | 141 | { |
141 | { "RequestMethod", "AddSession" }, | 142 | { "RequestMethod", "AddSession" }, |
142 | { "UserID", userID.ToString() } | 143 | { "UserID", userID.ToString() } |
143 | }; | 144 | }; |
145 | |||
144 | if (sessionID != UUID.Zero) | 146 | if (sessionID != UUID.Zero) |
145 | { | 147 | { |
146 | requestArgs["SessionID"] = sessionID.ToString(); | 148 | requestArgs["SessionID"] = sessionID.ToString(); |
147 | requestArgs["SecureSessionID"] = secureSessionID.ToString(); | 149 | requestArgs["SecureSessionID"] = secureSessionID.ToString(); |
148 | } | 150 | } |
149 | 151 | ||
150 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 152 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
151 | bool success = response["Success"].AsBoolean(); | 153 | bool success = response["Success"].AsBoolean(); |
152 | 154 | ||
153 | if (!success) | 155 | if (!success) |
@@ -158,15 +160,15 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
158 | 160 | ||
159 | public bool LogoutAgent(UUID sessionID) | 161 | public bool LogoutAgent(UUID sessionID) |
160 | { | 162 | { |
161 | // m_log.InfoFormat("[SIMIAN PRESENCE CONNECTOR]: Logout requested for agent with sessionID " + sessionID); | 163 | // m_log.InfoFormat("[SIMIAN PRESENCE CONNECTOR]: Logout requested for agent with sessionID " + sessionID); |
162 | 164 | ||
163 | NameValueCollection requestArgs = new NameValueCollection | 165 | NameValueCollection requestArgs = new NameValueCollection |
164 | { | 166 | { |
165 | { "RequestMethod", "RemoveSession" }, | 167 | { "RequestMethod", "RemoveSession" }, |
166 | { "SessionID", sessionID.ToString() } | 168 | { "SessionID", sessionID.ToString() } |
167 | }; | 169 | }; |
168 | 170 | ||
169 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 171 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
170 | bool success = response["Success"].AsBoolean(); | 172 | bool success = response["Success"].AsBoolean(); |
171 | 173 | ||
172 | if (!success) | 174 | if (!success) |
@@ -177,15 +179,15 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
177 | 179 | ||
178 | public bool LogoutRegionAgents(UUID regionID) | 180 | public bool LogoutRegionAgents(UUID regionID) |
179 | { | 181 | { |
180 | // m_log.InfoFormat("[SIMIAN PRESENCE CONNECTOR]: Logout requested for all agents in region " + regionID); | 182 | // m_log.InfoFormat("[SIMIAN PRESENCE CONNECTOR]: Logout requested for all agents in region " + regionID); |
181 | 183 | ||
182 | NameValueCollection requestArgs = new NameValueCollection | 184 | NameValueCollection requestArgs = new NameValueCollection |
183 | { | 185 | { |
184 | { "RequestMethod", "RemoveSessions" }, | 186 | { "RequestMethod", "RemoveSessions" }, |
185 | { "SceneID", regionID.ToString() } | 187 | { "SceneID", regionID.ToString() } |
186 | }; | 188 | }; |
187 | 189 | ||
188 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 190 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
189 | bool success = response["Success"].AsBoolean(); | 191 | bool success = response["Success"].AsBoolean(); |
190 | 192 | ||
191 | if (!success) | 193 | if (!success) |
@@ -202,49 +204,46 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
202 | 204 | ||
203 | public PresenceInfo GetAgent(UUID sessionID) | 205 | public PresenceInfo GetAgent(UUID sessionID) |
204 | { | 206 | { |
205 | // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting session data for agent with sessionID " + sessionID); | 207 | OSDMap sessionResponse = GetSessionDataFromSessionID(sessionID); |
206 | 208 | if (sessionResponse == null) | |
207 | NameValueCollection requestArgs = new NameValueCollection | ||
208 | { | ||
209 | { "RequestMethod", "GetSession" }, | ||
210 | { "SessionID", sessionID.ToString() } | ||
211 | }; | ||
212 | |||
213 | OSDMap sessionResponse = WebUtil.PostToService(m_serverUrl, requestArgs); | ||
214 | if (sessionResponse["Success"].AsBoolean()) | ||
215 | { | 209 | { |
216 | UUID userID = sessionResponse["UserID"].AsUUID(); | 210 | m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve session {0}: {1}",sessionID.ToString(),sessionResponse["Message"].AsString()); |
217 | m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting user data for " + userID); | 211 | return null; |
218 | |||
219 | requestArgs = new NameValueCollection | ||
220 | { | ||
221 | { "RequestMethod", "GetUser" }, | ||
222 | { "UserID", userID.ToString() } | ||
223 | }; | ||
224 | |||
225 | OSDMap userResponse = WebUtil.PostToService(m_serverUrl, requestArgs); | ||
226 | if (userResponse["Success"].AsBoolean()) | ||
227 | return ResponseToPresenceInfo(sessionResponse, userResponse); | ||
228 | else | ||
229 | m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for " + userID + ": " + userResponse["Message"].AsString()); | ||
230 | } | 212 | } |
231 | else | 213 | |
214 | UUID userID = sessionResponse["UserID"].AsUUID(); | ||
215 | OSDMap userResponse = GetUserData(userID); | ||
216 | if (userResponse == null) | ||
232 | { | 217 | { |
233 | m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve session " + sessionID + ": " + sessionResponse["Message"].AsString()); | 218 | m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for {0}: {1}",userID.ToString(),userResponse["Message"].AsString()); |
219 | return null; | ||
234 | } | 220 | } |
235 | 221 | ||
236 | return null; | 222 | return ResponseToPresenceInfo(sessionResponse); |
237 | } | 223 | } |
238 | 224 | ||
239 | public PresenceInfo[] GetAgents(string[] userIDs) | 225 | public PresenceInfo[] GetAgents(string[] userIDs) |
240 | { | 226 | { |
241 | List<PresenceInfo> presences = new List<PresenceInfo>(userIDs.Length); | 227 | List<PresenceInfo> presences = new List<PresenceInfo>(); |
228 | |||
229 | NameValueCollection requestArgs = new NameValueCollection | ||
230 | { | ||
231 | { "RequestMethod", "GetSessions" }, | ||
232 | { "UserIDList", String.Join(",",userIDs) } | ||
233 | }; | ||
242 | 234 | ||
243 | for (int i = 0; i < userIDs.Length; i++) | 235 | OSDMap sessionListResponse = SimianGrid.PostToService(m_serverUrl, requestArgs); |
236 | if (! sessionListResponse["Success"].AsBoolean()) | ||
244 | { | 237 | { |
245 | UUID userID; | 238 | m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve sessions: {0}",sessionListResponse["Message"].AsString()); |
246 | if (UUID.TryParse(userIDs[i], out userID) && userID != UUID.Zero) | 239 | return null; |
247 | presences.AddRange(GetSessions(userID)); | 240 | } |
241 | |||
242 | OSDArray sessionList = sessionListResponse["Sessions"] as OSDArray; | ||
243 | for (int i = 0; i < sessionList.Count; i++) | ||
244 | { | ||
245 | OSDMap sessionInfo = sessionList[i] as OSDMap; | ||
246 | presences.Add(ResponseToPresenceInfo(sessionInfo)); | ||
248 | } | 247 | } |
249 | 248 | ||
250 | return presences.ToArray(); | 249 | return presences.ToArray(); |
@@ -262,7 +261,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
262 | 261 | ||
263 | public bool LoggedOut(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) | 262 | public bool LoggedOut(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) |
264 | { | 263 | { |
265 | // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Logging out user " + userID); | 264 | // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Logging out user " + userID); |
266 | 265 | ||
267 | // Remove the session to mark this user offline | 266 | // Remove the session to mark this user offline |
268 | if (!LogoutAgent(sessionID)) | 267 | if (!LogoutAgent(sessionID)) |
@@ -270,13 +269,13 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
270 | 269 | ||
271 | // Save our last position as user data | 270 | // Save our last position as user data |
272 | NameValueCollection requestArgs = new NameValueCollection | 271 | NameValueCollection requestArgs = new NameValueCollection |
273 | { | 272 | { |
274 | { "RequestMethod", "AddUserData" }, | 273 | { "RequestMethod", "AddUserData" }, |
275 | { "UserID", userID.ToString() }, | 274 | { "UserID", userID.ToString() }, |
276 | { "LastLocation", SerializeLocation(regionID, lastPosition, lastLookAt) } | 275 | { "LastLocation", SerializeLocation(regionID, lastPosition, lastLookAt) } |
277 | }; | 276 | }; |
278 | 277 | ||
279 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 278 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
280 | bool success = response["Success"].AsBoolean(); | 279 | bool success = response["Success"].AsBoolean(); |
281 | 280 | ||
282 | if (!success) | 281 | if (!success) |
@@ -287,16 +286,16 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
287 | 286 | ||
288 | public bool SetHome(string userID, UUID regionID, Vector3 position, Vector3 lookAt) | 287 | public bool SetHome(string userID, UUID regionID, Vector3 position, Vector3 lookAt) |
289 | { | 288 | { |
290 | // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Setting home location for user " + userID); | 289 | // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Setting home location for user " + userID); |
291 | 290 | ||
292 | NameValueCollection requestArgs = new NameValueCollection | 291 | NameValueCollection requestArgs = new NameValueCollection |
293 | { | 292 | { |
294 | { "RequestMethod", "AddUserData" }, | 293 | { "RequestMethod", "AddUserData" }, |
295 | { "UserID", userID.ToString() }, | 294 | { "UserID", userID.ToString() }, |
296 | { "HomeLocation", SerializeLocation(regionID, position, lookAt) } | 295 | { "HomeLocation", SerializeLocation(regionID, position, lookAt) } |
297 | }; | 296 | }; |
298 | 297 | ||
299 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 298 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
300 | bool success = response["Success"].AsBoolean(); | 299 | bool success = response["Success"].AsBoolean(); |
301 | 300 | ||
302 | if (!success) | 301 | if (!success) |
@@ -312,24 +311,19 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
312 | 311 | ||
313 | public GridUserInfo GetGridUserInfo(string user) | 312 | public GridUserInfo GetGridUserInfo(string user) |
314 | { | 313 | { |
315 | // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting session data for agent " + user); | 314 | // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting session data for agent " + user); |
316 | 315 | ||
317 | UUID userID = new UUID(user); | 316 | UUID userID = new UUID(user); |
318 | // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting user data for " + userID); | 317 | OSDMap userResponse = GetUserData(userID); |
319 | 318 | ||
320 | NameValueCollection requestArgs = new NameValueCollection | 319 | if (userResponse == null) |
321 | { | 320 | { |
322 | { "RequestMethod", "GetUser" }, | 321 | m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for {0}", userID); |
323 | { "UserID", userID.ToString() } | 322 | } |
324 | }; | ||
325 | 323 | ||
326 | OSDMap userResponse = WebUtil.PostToService(m_serverUrl, requestArgs); | 324 | // Note that ResponseToGridUserInfo properly checks for and returns a null if passed a null. |
327 | if (userResponse["Success"].AsBoolean()) | 325 | return ResponseToGridUserInfo(userResponse); |
328 | return ResponseToGridUserInfo(userResponse); | ||
329 | else | ||
330 | m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for " + userID + ": " + userResponse["Message"].AsString()); | ||
331 | 326 | ||
332 | return null; | ||
333 | } | 327 | } |
334 | 328 | ||
335 | #endregion | 329 | #endregion |
@@ -338,67 +332,51 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
338 | 332 | ||
339 | private OSDMap GetUserData(UUID userID) | 333 | private OSDMap GetUserData(UUID userID) |
340 | { | 334 | { |
341 | // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting user data for " + userID); | 335 | // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting user data for " + userID); |
342 | 336 | ||
343 | NameValueCollection requestArgs = new NameValueCollection | 337 | NameValueCollection requestArgs = new NameValueCollection |
344 | { | 338 | { |
345 | { "RequestMethod", "GetUser" }, | 339 | { "RequestMethod", "GetUser" }, |
346 | { "UserID", userID.ToString() } | 340 | { "UserID", userID.ToString() } |
347 | }; | 341 | }; |
348 | 342 | ||
349 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 343 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
350 | if (response["Success"].AsBoolean() && response["User"] is OSDMap) | 344 | if (response["Success"].AsBoolean() && response["User"] is OSDMap) |
351 | return response; | 345 | return response; |
352 | else | ||
353 | m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for " + userID + ": " + response["Message"].AsString()); | ||
354 | 346 | ||
347 | m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for {0}; {1}",userID.ToString(),response["Message"].AsString()); | ||
355 | return null; | 348 | return null; |
356 | } | 349 | } |
357 | 350 | ||
358 | private List<PresenceInfo> GetSessions(UUID userID) | 351 | private OSDMap GetSessionDataFromSessionID(UUID sessionID) |
359 | { | 352 | { |
360 | List<PresenceInfo> presences = new List<PresenceInfo>(1); | 353 | NameValueCollection requestArgs = new NameValueCollection |
361 | |||
362 | OSDMap userResponse = GetUserData(userID); | ||
363 | if (userResponse != null) | ||
364 | { | ||
365 | // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting sessions for " + userID); | ||
366 | |||
367 | NameValueCollection requestArgs = new NameValueCollection | ||
368 | { | 354 | { |
369 | { "RequestMethod", "GetSession" }, | 355 | { "RequestMethod", "GetSession" }, |
370 | { "UserID", userID.ToString() } | 356 | { "SessionID", sessionID.ToString() } |
371 | }; | 357 | }; |
372 | 358 | ||
373 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 359 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
374 | if (response["Success"].AsBoolean()) | 360 | if (response["Success"].AsBoolean()) |
375 | { | 361 | return response; |
376 | PresenceInfo presence = ResponseToPresenceInfo(response, userResponse); | ||
377 | if (presence != null) | ||
378 | presences.Add(presence); | ||
379 | } | ||
380 | // else | ||
381 | // { | ||
382 | // m_log.Debug("[SIMIAN PRESENCE CONNECTOR]: No session returned for " + userID + ": " + response["Message"].AsString()); | ||
383 | // } | ||
384 | } | ||
385 | 362 | ||
386 | return presences; | 363 | m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve session data for {0}; {1}",sessionID.ToString(),response["Message"].AsString()); |
364 | return null; | ||
387 | } | 365 | } |
388 | 366 | ||
389 | private bool UpdateSession(UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) | 367 | private bool UpdateSession(UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) |
390 | { | 368 | { |
391 | // Save our current location as session data | 369 | // Save our current location as session data |
392 | NameValueCollection requestArgs = new NameValueCollection | 370 | NameValueCollection requestArgs = new NameValueCollection |
393 | { | 371 | { |
394 | { "RequestMethod", "UpdateSession" }, | 372 | { "RequestMethod", "UpdateSession" }, |
395 | { "SessionID", sessionID.ToString() }, | 373 | { "SessionID", sessionID.ToString() }, |
396 | { "SceneID", regionID.ToString() }, | 374 | { "SceneID", regionID.ToString() }, |
397 | { "ScenePosition", lastPosition.ToString() }, | 375 | { "ScenePosition", lastPosition.ToString() }, |
398 | { "SceneLookAt", lastLookAt.ToString() } | 376 | { "SceneLookAt", lastLookAt.ToString() } |
399 | }; | 377 | }; |
400 | 378 | ||
401 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 379 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
402 | bool success = response["Success"].AsBoolean(); | 380 | bool success = response["Success"].AsBoolean(); |
403 | 381 | ||
404 | if (!success) | 382 | if (!success) |
@@ -407,7 +385,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
407 | return success; | 385 | return success; |
408 | } | 386 | } |
409 | 387 | ||
410 | private PresenceInfo ResponseToPresenceInfo(OSDMap sessionResponse, OSDMap userResponse) | 388 | private PresenceInfo ResponseToPresenceInfo(OSDMap sessionResponse) |
411 | { | 389 | { |
412 | if (sessionResponse == null) | 390 | if (sessionResponse == null) |
413 | return null; | 391 | return null; |
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs b/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs index bd8069f..684a0db 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs | |||
@@ -392,7 +392,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
392 | { "UserID", client.AgentId.ToString() } | 392 | { "UserID", client.AgentId.ToString() } |
393 | }; | 393 | }; |
394 | 394 | ||
395 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 395 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
396 | string email = response["Email"].AsString(); | 396 | string email = response["Email"].AsString(); |
397 | 397 | ||
398 | if (!response["Success"].AsBoolean()) | 398 | if (!response["Success"].AsBoolean()) |
@@ -443,7 +443,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
443 | { key, OSDParser.SerializeJsonString(value) } | 443 | { key, OSDParser.SerializeJsonString(value) } |
444 | }; | 444 | }; |
445 | 445 | ||
446 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 446 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
447 | bool success = response["Success"].AsBoolean(); | 447 | bool success = response["Success"].AsBoolean(); |
448 | 448 | ||
449 | if (!success) | 449 | if (!success) |
@@ -462,7 +462,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
462 | { "UserID", userID.ToString() } | 462 | { "UserID", userID.ToString() } |
463 | }; | 463 | }; |
464 | 464 | ||
465 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 465 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
466 | if (response["Success"].AsBoolean() && response["User"] is OSDMap) | 466 | if (response["Success"].AsBoolean() && response["User"] is OSDMap) |
467 | { | 467 | { |
468 | return (OSDMap)response["User"]; | 468 | return (OSDMap)response["User"]; |
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs index fcb5115..fdc8697 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianUserAccountServiceConnector.cs | |||
@@ -165,7 +165,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
165 | { "NameQuery", query } | 165 | { "NameQuery", query } |
166 | }; | 166 | }; |
167 | 167 | ||
168 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 168 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
169 | if (response["Success"].AsBoolean()) | 169 | if (response["Success"].AsBoolean()) |
170 | { | 170 | { |
171 | OSDArray array = response["Users"] as OSDArray; | 171 | OSDArray array = response["Users"] as OSDArray; |
@@ -209,7 +209,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
209 | { "AccessLevel", data.UserLevel.ToString() } | 209 | { "AccessLevel", data.UserLevel.ToString() } |
210 | }; | 210 | }; |
211 | 211 | ||
212 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 212 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
213 | 213 | ||
214 | if (response["Success"].AsBoolean()) | 214 | if (response["Success"].AsBoolean()) |
215 | { | 215 | { |
@@ -224,7 +224,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
224 | { "UserTitle", data.UserTitle } | 224 | { "UserTitle", data.UserTitle } |
225 | }; | 225 | }; |
226 | 226 | ||
227 | response = WebUtil.PostToService(m_serverUrl, requestArgs); | 227 | response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
228 | bool success = response["Success"].AsBoolean(); | 228 | bool success = response["Success"].AsBoolean(); |
229 | 229 | ||
230 | if (success) | 230 | if (success) |
@@ -257,7 +257,7 @@ namespace OpenSim.Services.Connectors.SimianGrid | |||
257 | string lookupValue = (requestArgs.Count > 1) ? requestArgs[1] : "(Unknown)"; | 257 | string lookupValue = (requestArgs.Count > 1) ? requestArgs[1] : "(Unknown)"; |
258 | // m_log.DebugFormat("[SIMIAN ACCOUNT CONNECTOR]: Looking up user account with query: " + lookupValue); | 258 | // m_log.DebugFormat("[SIMIAN ACCOUNT CONNECTOR]: Looking up user account with query: " + lookupValue); |
259 | 259 | ||
260 | OSDMap response = WebUtil.PostToService(m_serverUrl, requestArgs); | 260 | OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); |
261 | if (response["Success"].AsBoolean()) | 261 | if (response["Success"].AsBoolean()) |
262 | { | 262 | { |
263 | OSDMap user = response["User"] as OSDMap; | 263 | OSDMap user = response["User"] as OSDMap; |
diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs index ef2494a..0e74073 100644 --- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs | |||
@@ -79,11 +79,27 @@ namespace OpenSim.Services.Connectors.Simulation | |||
79 | return "agent/"; | 79 | return "agent/"; |
80 | } | 80 | } |
81 | 81 | ||
82 | protected virtual void PackData(OSDMap args, AgentCircuitData aCircuit, GridRegion destination, uint flags) | ||
83 | { | ||
84 | args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString()); | ||
85 | args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString()); | ||
86 | args["destination_name"] = OSD.FromString(destination.RegionName); | ||
87 | args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString()); | ||
88 | args["teleport_flags"] = OSD.FromString(flags.ToString()); | ||
89 | } | ||
90 | |||
82 | public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason) | 91 | public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason) |
83 | { | 92 | { |
84 | // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CreateAgent start"); | 93 | string tmp = String.Empty; |
85 | 94 | return CreateAgent(destination, aCircuit, flags, out tmp, out reason); | |
95 | } | ||
96 | |||
97 | public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string myipaddress, out string reason) | ||
98 | { | ||
99 | m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: Creating agent at {0}", destination.ServerURI); | ||
86 | reason = String.Empty; | 100 | reason = String.Empty; |
101 | myipaddress = String.Empty; | ||
102 | |||
87 | if (destination == null) | 103 | if (destination == null) |
88 | { | 104 | { |
89 | reason = "Destination not found"; | 105 | reason = "Destination not found"; |
@@ -96,12 +112,7 @@ namespace OpenSim.Services.Connectors.Simulation | |||
96 | try | 112 | try |
97 | { | 113 | { |
98 | OSDMap args = aCircuit.PackAgentCircuitData(); | 114 | OSDMap args = aCircuit.PackAgentCircuitData(); |
99 | 115 | PackData(args, aCircuit, destination, flags); | |
100 | args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString()); | ||
101 | args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString()); | ||
102 | args["destination_name"] = OSD.FromString(destination.RegionName); | ||
103 | args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString()); | ||
104 | args["teleport_flags"] = OSD.FromString(flags.ToString()); | ||
105 | 116 | ||
106 | OSDMap result = WebUtil.PostToServiceCompressed(uri, args, 30000); | 117 | OSDMap result = WebUtil.PostToServiceCompressed(uri, args, 30000); |
107 | bool success = result["success"].AsBoolean(); | 118 | bool success = result["success"].AsBoolean(); |
@@ -111,6 +122,7 @@ namespace OpenSim.Services.Connectors.Simulation | |||
111 | 122 | ||
112 | reason = data["reason"].AsString(); | 123 | reason = data["reason"].AsString(); |
113 | success = data["success"].AsBoolean(); | 124 | success = data["success"].AsBoolean(); |
125 | myipaddress = data["your_ip"].AsString(); | ||
114 | return success; | 126 | return success; |
115 | } | 127 | } |
116 | 128 | ||
@@ -125,6 +137,7 @@ namespace OpenSim.Services.Connectors.Simulation | |||
125 | 137 | ||
126 | reason = data["reason"].AsString(); | 138 | reason = data["reason"].AsString(); |
127 | success = data["success"].AsBoolean(); | 139 | success = data["success"].AsBoolean(); |
140 | myipaddress = data["your_ip"].AsString(); | ||
128 | m_log.WarnFormat( | 141 | m_log.WarnFormat( |
129 | "[REMOTE SIMULATION CONNECTOR]: Remote simulator {0} did not accept compressed transfer, suggest updating it.", destination.RegionName); | 142 | "[REMOTE SIMULATION CONNECTOR]: Remote simulator {0} did not accept compressed transfer, suggest updating it.", destination.RegionName); |
130 | return success; | 143 | return success; |
@@ -229,7 +242,7 @@ namespace OpenSim.Services.Connectors.Simulation | |||
229 | /// </summary> | 242 | /// </summary> |
230 | private bool UpdateAgent(GridRegion destination, IAgentData cAgentData, int timeout) | 243 | private bool UpdateAgent(GridRegion destination, IAgentData cAgentData, int timeout) |
231 | { | 244 | { |
232 | // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: UpdateAgent start"); | 245 | // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: UpdateAgent in {0}", destination.ServerURI); |
233 | 246 | ||
234 | // Eventually, we want to use a caps url instead of the agentID | 247 | // Eventually, we want to use a caps url instead of the agentID |
235 | string uri = destination.ServerURI + AgentPath() + cAgentData.AgentID + "/"; | 248 | string uri = destination.ServerURI + AgentPath() + cAgentData.AgentID + "/"; |
@@ -259,41 +272,6 @@ namespace OpenSim.Services.Connectors.Simulation | |||
259 | return false; | 272 | return false; |
260 | } | 273 | } |
261 | 274 | ||
262 | /// <summary> | ||
263 | /// Not sure what sequence causes this function to be invoked. The only calling | ||
264 | /// path is through the GET method | ||
265 | /// </summary> | ||
266 | public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent) | ||
267 | { | ||
268 | // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: RetrieveAgent start"); | ||
269 | |||
270 | agent = null; | ||
271 | |||
272 | // Eventually, we want to use a caps url instead of the agentID | ||
273 | string uri = destination.ServerURI + AgentPath() + id + "/" + destination.RegionID.ToString() + "/"; | ||
274 | |||
275 | try | ||
276 | { | ||
277 | OSDMap result = WebUtil.GetFromService(uri, 10000); | ||
278 | if (result["Success"].AsBoolean()) | ||
279 | { | ||
280 | // OSDMap args = Util.GetOSDMap(result["_RawResult"].AsString()); | ||
281 | OSDMap args = (OSDMap)result["_Result"]; | ||
282 | if (args != null) | ||
283 | { | ||
284 | agent = new CompleteAgentData(); | ||
285 | agent.Unpack(args, null); | ||
286 | return true; | ||
287 | } | ||
288 | } | ||
289 | } | ||
290 | catch (Exception e) | ||
291 | { | ||
292 | m_log.Warn("[REMOTE SIMULATION CONNECTOR]: UpdateAgent failed with exception: " + e.ToString()); | ||
293 | } | ||
294 | |||
295 | return false; | ||
296 | } | ||
297 | 275 | ||
298 | /// <summary> | 276 | /// <summary> |
299 | /// </summary> | 277 | /// </summary> |
@@ -392,35 +370,25 @@ namespace OpenSim.Services.Connectors.Simulation | |||
392 | return true; | 370 | return true; |
393 | } | 371 | } |
394 | 372 | ||
395 | private bool CloseAgent(GridRegion destination, UUID id, bool ChildOnly) | 373 | /// <summary> |
374 | /// </summary> | ||
375 | public bool CloseAgent(GridRegion destination, UUID id, string auth_code) | ||
396 | { | 376 | { |
397 | // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CloseAgent start"); | 377 | string uri = destination.ServerURI + AgentPath() + id + "/" + destination.RegionID.ToString() + "/?auth=" + auth_code; |
398 | Util.FireAndForget(x => { | 378 | m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CloseAgent {0}", uri); |
399 | string uri = destination.ServerURI + AgentPath() + id + "/" + destination.RegionID.ToString() + "/"; | ||
400 | 379 | ||
401 | try | 380 | try |
402 | { | 381 | { |
403 | WebUtil.ServiceOSDRequest(uri, null, "DELETE", 10000, false); | 382 | WebUtil.ServiceOSDRequest(uri, null, "DELETE", 10000, false); |
404 | } | 383 | } |
405 | catch (Exception e) | 384 | catch (Exception e) |
406 | { | 385 | { |
407 | m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR] CloseAgent failed with exception; {0}",e.ToString()); | 386 | m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR] CloseAgent failed with exception; {0}",e.ToString()); |
408 | } | 387 | } |
409 | }); | ||
410 | 388 | ||
411 | return true; | 389 | return true; |
412 | } | 390 | } |
413 | 391 | ||
414 | public bool CloseChildAgent(GridRegion destination, UUID id) | ||
415 | { | ||
416 | return CloseAgent(destination, id, true); | ||
417 | } | ||
418 | |||
419 | public bool CloseAgent(GridRegion destination, UUID id) | ||
420 | { | ||
421 | return CloseAgent(destination, id, false); | ||
422 | } | ||
423 | |||
424 | #endregion Agents | 392 | #endregion Agents |
425 | 393 | ||
426 | #region Objects | 394 | #region Objects |