diff options
author | Diva Canto | 2011-06-13 09:13:44 -0700 |
---|---|---|
committer | Diva Canto | 2011-06-13 09:13:44 -0700 |
commit | ecb28ae130d1fc212c72af887fc75ae2bf64ab97 (patch) | |
tree | 40ab53e950d7e15b0cbd0e9f90d9eb7a286be139 /OpenSim/Services | |
parent | Same processing of the "/" in the MapImageService Cap as the one in the login... (diff) | |
download | opensim-SC_OLD-ecb28ae130d1fc212c72af887fc75ae2bf64ab97.zip opensim-SC_OLD-ecb28ae130d1fc212c72af887fc75ae2bf64ab97.tar.gz opensim-SC_OLD-ecb28ae130d1fc212c72af887fc75ae2bf64ab97.tar.bz2 opensim-SC_OLD-ecb28ae130d1fc212c72af887fc75ae2bf64ab97.tar.xz |
V2 map now working in grids too. WARNING: A few visible configuration variables added in order for this to work. See .ini.example changes
Diffstat (limited to 'OpenSim/Services')
-rw-r--r-- | OpenSim/Services/Connectors/MapImage/MapImageServiceConnector.cs | 81 | ||||
-rw-r--r-- | OpenSim/Services/MapImageService/MapImageService.cs | 2 |
2 files changed, 41 insertions, 42 deletions
diff --git a/OpenSim/Services/Connectors/MapImage/MapImageServiceConnector.cs b/OpenSim/Services/Connectors/MapImage/MapImageServiceConnector.cs index ff0e9d9..520d639 100644 --- a/OpenSim/Services/Connectors/MapImage/MapImageServiceConnector.cs +++ b/OpenSim/Services/Connectors/MapImage/MapImageServiceConnector.cs | |||
@@ -36,6 +36,7 @@ using Nini.Config; | |||
36 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
37 | using OpenSim.Framework.Console; | 37 | using OpenSim.Framework.Console; |
38 | using OpenSim.Framework.Communications; | 38 | using OpenSim.Framework.Communications; |
39 | using OpenSim.Server.Base; | ||
39 | using OpenSim.Services.Interfaces; | 40 | using OpenSim.Services.Interfaces; |
40 | using OpenMetaverse; | 41 | using OpenMetaverse; |
41 | using OpenMetaverse.StructuredData; | 42 | using OpenMetaverse.StructuredData; |
@@ -83,60 +84,57 @@ namespace OpenSim.Services.Connectors | |||
83 | throw new Exception("MapImage connector init error"); | 84 | throw new Exception("MapImage connector init error"); |
84 | } | 85 | } |
85 | m_ServerURI = serviceURI; | 86 | m_ServerURI = serviceURI; |
87 | m_ServerURI = serviceURI.TrimEnd('/'); | ||
86 | } | 88 | } |
87 | 89 | ||
88 | public bool AddMapTile(int x, int y, byte[] pngData, out string reason) | 90 | public bool AddMapTile(int x, int y, byte[] jpgData, out string reason) |
89 | { | 91 | { |
90 | List<MultipartForm.Element> postParameters = new List<MultipartForm.Element>() | 92 | reason = string.Empty; |
91 | { | ||
92 | new MultipartForm.Parameter("X", x.ToString()), | ||
93 | new MultipartForm.Parameter("Y", y.ToString()), | ||
94 | new MultipartForm.File("Tile", "tile.png", "image/png", pngData) | ||
95 | }; | ||
96 | |||
97 | reason = string.Empty; | ||
98 | int tickstart = Util.EnvironmentTickCount(); | 93 | int tickstart = Util.EnvironmentTickCount(); |
94 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
95 | sendData["X"] = x.ToString(); | ||
96 | sendData["Y"] = y.ToString(); | ||
97 | sendData["TYPE"] = "image/jpeg"; | ||
98 | sendData["DATA"] = Convert.ToBase64String(jpgData); | ||
99 | |||
100 | string reqString = ServerUtils.BuildQueryString(sendData); | ||
99 | 101 | ||
100 | // Make the remote storage request | ||
101 | try | 102 | try |
102 | { | 103 | { |
103 | HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_ServerURI); | 104 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", |
104 | request.Timeout = 20000; | 105 | m_ServerURI + "/map", |
105 | request.ReadWriteTimeout = 5000; | 106 | reqString); |
106 | 107 | if (reply != string.Empty) | |
107 | using (HttpWebResponse response = MultipartForm.Post(request, postParameters)) | ||
108 | { | 108 | { |
109 | using (Stream responseStream = response.GetResponseStream()) | 109 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); |
110 | |||
111 | if (replyData.ContainsKey("Result") && (replyData["Result"].ToString().ToLower() == "success")) | ||
110 | { | 112 | { |
111 | string responseStr = responseStream.GetStreamString(); | 113 | return true; |
112 | OSD responseOSD = OSDParser.Deserialize(responseStr); | ||
113 | if (responseOSD.Type == OSDType.Map) | ||
114 | { | ||
115 | OSDMap responseMap = (OSDMap)responseOSD; | ||
116 | if (responseMap["Success"].AsBoolean()) | ||
117 | return true; | ||
118 | |||
119 | reason = "Upload failed: " + responseMap["Message"].AsString(); | ||
120 | } | ||
121 | else | ||
122 | { | ||
123 | reason = "Response format was invalid:\n" + responseStr; | ||
124 | } | ||
125 | } | 114 | } |
115 | else if (replyData.ContainsKey("Result") && (replyData["Result"].ToString().ToLower() == "failure")) | ||
116 | { | ||
117 | m_log.DebugFormat("[MAP IMAGE CONNECTOR]: Registration failed: {0}", replyData["Message"].ToString()); | ||
118 | reason = replyData["Message"].ToString(); | ||
119 | return false; | ||
120 | } | ||
121 | else if (!replyData.ContainsKey("Result")) | ||
122 | { | ||
123 | m_log.DebugFormat("[MAP IMAGE CONNECTOR]: reply data does not contain result field"); | ||
124 | } | ||
125 | else | ||
126 | { | ||
127 | m_log.DebugFormat("[MAP IMAGE CONNECTOR]: unexpected result {0}", replyData["Result"].ToString()); | ||
128 | reason = "Unexpected result " + replyData["Result"].ToString(); | ||
129 | } | ||
130 | |||
126 | } | 131 | } |
132 | else | ||
133 | m_log.DebugFormat("[MAP IMAGE CONNECTOR]: RegisterRegion received null reply"); | ||
127 | } | 134 | } |
128 | catch (WebException we) | 135 | catch (Exception e) |
129 | { | ||
130 | reason = we.Message; | ||
131 | if (we.Status == WebExceptionStatus.ProtocolError) | ||
132 | { | ||
133 | HttpWebResponse webResponse = (HttpWebResponse)we.Response; | ||
134 | reason = String.Format("[{0}] {1}", webResponse.StatusCode, webResponse.StatusDescription); | ||
135 | } | ||
136 | } | ||
137 | catch (Exception ex) | ||
138 | { | 136 | { |
139 | reason = ex.Message; | 137 | m_log.DebugFormat("[MAP IMAGE CONNECTOR]: Exception when contacting grid server: {0}", e.Message); |
140 | } | 138 | } |
141 | finally | 139 | finally |
142 | { | 140 | { |
@@ -146,6 +144,7 @@ namespace OpenSim.Services.Connectors | |||
146 | } | 144 | } |
147 | 145 | ||
148 | return false; | 146 | return false; |
147 | |||
149 | } | 148 | } |
150 | 149 | ||
151 | public byte[] GetMapTile(string fileName, out string format) | 150 | public byte[] GetMapTile(string fileName, out string format) |
diff --git a/OpenSim/Services/MapImageService/MapImageService.cs b/OpenSim/Services/MapImageService/MapImageService.cs index 27722bb..7e7391c 100644 --- a/OpenSim/Services/MapImageService/MapImageService.cs +++ b/OpenSim/Services/MapImageService/MapImageService.cs | |||
@@ -143,7 +143,7 @@ namespace OpenSim.Services.MapImageService | |||
143 | if (File.Exists(fullName)) | 143 | if (File.Exists(fullName)) |
144 | { | 144 | { |
145 | format = Path.GetExtension(fileName).ToLower(); | 145 | format = Path.GetExtension(fileName).ToLower(); |
146 | m_log.DebugFormat("[MAP IMAGE SERVICE]: Found file {0}, extension {1}", fileName, format); | 146 | //m_log.DebugFormat("[MAP IMAGE SERVICE]: Found file {0}, extension {1}", fileName, format); |
147 | return File.ReadAllBytes(fullName); | 147 | return File.ReadAllBytes(fullName); |
148 | } | 148 | } |
149 | else if (File.Exists(m_WaterTileFile)) | 149 | else if (File.Exists(m_WaterTileFile)) |