aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianGridMaptileModule.cs131
1 files changed, 75 insertions, 56 deletions
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
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Collections.Specialized;
30using System.Reflection; 31using System.Reflection;
31using System.Net; 32using System.Net;
32using System.IO; 33using System.IO;
@@ -43,7 +44,8 @@ using OpenSim.Region.Framework.Scenes;
43using OpenMetaverse; 44using OpenMetaverse;
44using OpenMetaverse.StructuredData; 45using OpenMetaverse.StructuredData;
45 46
46namespace OpenSim.Region.OptionalModules.Simian 47//namespace OpenSim.Region.OptionalModules.Simian
48namespace 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