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