diff options
Diffstat (limited to 'OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs')
-rw-r--r-- | OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs | 69 |
1 files changed, 34 insertions, 35 deletions
diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs index 2f263ae..47d0cce 100644 --- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs | |||
@@ -171,41 +171,45 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
171 | // Let's wait for the response | 171 | // Let's wait for the response |
172 | //m_log.Info("[USER AGENT CONNECTOR]: Waiting for a reply after DoCreateChildAgentCall"); | 172 | //m_log.Info("[USER AGENT CONNECTOR]: Waiting for a reply after DoCreateChildAgentCall"); |
173 | 173 | ||
174 | WebResponse webResponse = null; | ||
175 | StreamReader sr = null; | ||
176 | try | 174 | try |
177 | { | 175 | { |
178 | webResponse = AgentCreateRequest.GetResponse(); | 176 | using (WebResponse webResponse = AgentCreateRequest.GetResponse()) |
179 | if (webResponse == null) | ||
180 | { | 177 | { |
181 | m_log.Info("[USER AGENT CONNECTOR]: Null reply on DoCreateChildAgentCall post"); | 178 | if (webResponse == null) |
182 | } | ||
183 | else | ||
184 | { | ||
185 | |||
186 | sr = new StreamReader(webResponse.GetResponseStream()); | ||
187 | string response = sr.ReadToEnd().Trim(); | ||
188 | m_log.InfoFormat("[USER AGENT CONNECTOR]: DoCreateChildAgentCall reply was {0} ", response); | ||
189 | |||
190 | if (!String.IsNullOrEmpty(response)) | ||
191 | { | 179 | { |
192 | try | 180 | m_log.Info("[USER AGENT CONNECTOR]: Null reply on DoCreateChildAgentCall post"); |
193 | { | 181 | } |
194 | // we assume we got an OSDMap back | 182 | else |
195 | OSDMap r = Util.GetOSDMap(response); | 183 | { |
196 | bool success = r["success"].AsBoolean(); | 184 | using (Stream s = webResponse.GetResponseStream()) |
197 | reason = r["reason"].AsString(); | ||
198 | return success; | ||
199 | } | ||
200 | catch (NullReferenceException e) | ||
201 | { | 185 | { |
202 | m_log.InfoFormat("[USER AGENT CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", e.Message); | 186 | using (StreamReader sr = new StreamReader(s)) |
203 | 187 | { | |
204 | // check for old style response | 188 | string response = sr.ReadToEnd().Trim(); |
205 | if (response.ToLower().StartsWith("true")) | 189 | m_log.InfoFormat("[USER AGENT CONNECTOR]: DoCreateChildAgentCall reply was {0} ", response); |
206 | return true; | 190 | |
207 | 191 | if (!String.IsNullOrEmpty(response)) | |
208 | return false; | 192 | { |
193 | try | ||
194 | { | ||
195 | // we assume we got an OSDMap back | ||
196 | OSDMap r = Util.GetOSDMap(response); | ||
197 | bool success = r["success"].AsBoolean(); | ||
198 | reason = r["reason"].AsString(); | ||
199 | return success; | ||
200 | } | ||
201 | catch (NullReferenceException e) | ||
202 | { | ||
203 | m_log.InfoFormat("[USER AGENT CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", e.Message); | ||
204 | |||
205 | // check for old style response | ||
206 | if (response.ToLower().StartsWith("true")) | ||
207 | return true; | ||
208 | |||
209 | return false; | ||
210 | } | ||
211 | } | ||
212 | } | ||
209 | } | 213 | } |
210 | } | 214 | } |
211 | } | 215 | } |
@@ -216,11 +220,6 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
216 | reason = "Destination did not reply"; | 220 | reason = "Destination did not reply"; |
217 | return false; | 221 | return false; |
218 | } | 222 | } |
219 | finally | ||
220 | { | ||
221 | if (sr != null) | ||
222 | sr.Close(); | ||
223 | } | ||
224 | 223 | ||
225 | return true; | 224 | return true; |
226 | 225 | ||