aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/Connectors
diff options
context:
space:
mode:
authorMelanie2010-08-21 00:32:26 +0100
committerMelanie2010-08-21 00:32:26 +0100
commitf8ff98577ef3e576326c6eea28cb12ebb4e0bdc4 (patch)
tree3ef10e646ddda95929142eb2c3774b42d0923b3b /OpenSim/Services/Connectors
parentForward-port a small improvement to the land out connector (diff)
parentForward-port a small improvement to the land out connector (diff)
downloadopensim-SC-f8ff98577ef3e576326c6eea28cb12ebb4e0bdc4.zip
opensim-SC-f8ff98577ef3e576326c6eea28cb12ebb4e0bdc4.tar.gz
opensim-SC-f8ff98577ef3e576326c6eea28cb12ebb4e0bdc4.tar.bz2
opensim-SC-f8ff98577ef3e576326c6eea28cb12ebb4e0bdc4.tar.xz
Merge branch 'master' into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Services/Connectors')
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs44
-rw-r--r--OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs7
-rw-r--r--OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs83
3 files changed, 107 insertions, 27 deletions
diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
index 6f159a0..cabee4c 100644
--- a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs
@@ -38,6 +38,7 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion;
38 38
39using OpenMetaverse; 39using OpenMetaverse;
40using OpenMetaverse.Imaging; 40using OpenMetaverse.Imaging;
41using OpenMetaverse.StructuredData;
41using Nwc.XmlRpc; 42using Nwc.XmlRpc;
42using log4net; 43using log4net;
43 44
@@ -278,5 +279,48 @@ namespace OpenSim.Services.Connectors.Hypergrid
278 return null; 279 return null;
279 } 280 }
280 281
282 public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string myipaddress, out string reason)
283 {
284 HttpWebRequest AgentCreateRequest = null;
285 myipaddress = String.Empty;
286 reason = String.Empty;
287
288 if (SendRequest(destination, aCircuit, flags, out reason, out AgentCreateRequest))
289 {
290 string response = GetResponse(AgentCreateRequest, out reason);
291 bool success = true;
292 UnpackResponse(response, out success, out reason, out myipaddress);
293 return success;
294 }
295
296 return false;
297 }
298
299 protected void UnpackResponse(string response, out bool result, out string reason, out string ipaddress)
300 {
301 result = true;
302 reason = string.Empty;
303 ipaddress = string.Empty;
304
305 if (!String.IsNullOrEmpty(response))
306 {
307 try
308 {
309 // we assume we got an OSDMap back
310 OSDMap r = Util.GetOSDMap(response);
311 result = r["success"].AsBoolean();
312 reason = r["reason"].AsString();
313 ipaddress = r["your_ip"].AsString();
314 }
315 catch (NullReferenceException e)
316 {
317 m_log.InfoFormat("[GATEKEEPER SERVICE CONNECTOR]: exception on UnpackResponse of DoCreateChildAgentCall {0}", e.Message);
318 reason = "Internal error";
319 result = false;
320 }
321 }
322 }
323
324
281 } 325 }
282} 326}
diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
index 69dff3c..c1e5949 100644
--- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs
@@ -73,6 +73,13 @@ namespace OpenSim.Services.Connectors.Hypergrid
73 { 73 {
74 } 74 }
75 75
76 public bool LoginAgentToGrid(AgentCircuitData agent, GridRegion gatekeeper, GridRegion finalDestination, IPEndPoint ipaddress, out string reason)
77 {
78 // not available over remote calls
79 reason = "Method not available over remote calls";
80 return false;
81 }
82
76 public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, out string reason) 83 public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, out string reason)
77 { 84 {
78 reason = String.Empty; 85 reason = String.Empty;
diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
index 957df35..9e30044 100644
--- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
@@ -77,8 +77,26 @@ namespace OpenSim.Services.Connectors.Simulation
77 77
78 public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason) 78 public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason)
79 { 79 {
80 HttpWebRequest AgentCreateRequest = null;
80 reason = String.Empty; 81 reason = String.Empty;
81 82
83 if (SendRequest(destination, aCircuit, flags, out reason, out AgentCreateRequest))
84 {
85 string response = GetResponse(AgentCreateRequest, out reason);
86 bool success = true;
87 UnpackResponse(response, out success, out reason);
88 return success;
89 }
90
91 return false;
92 }
93
94
95 protected bool SendRequest(GridRegion destination, AgentCircuitData aCircuit, uint flags, out string reason, out HttpWebRequest AgentCreateRequest)
96 {
97 reason = String.Empty;
98 AgentCreateRequest = null;
99
82 if (destination == null) 100 if (destination == null)
83 { 101 {
84 reason = "Destination is null"; 102 reason = "Destination is null";
@@ -101,7 +119,7 @@ namespace OpenSim.Services.Connectors.Simulation
101 119
102 //Console.WriteLine(" >>> DoCreateChildAgentCall <<< " + uri); 120 //Console.WriteLine(" >>> DoCreateChildAgentCall <<< " + uri);
103 121
104 HttpWebRequest AgentCreateRequest = (HttpWebRequest)WebRequest.Create(uri); 122 AgentCreateRequest = (HttpWebRequest)WebRequest.Create(uri);
105 AgentCreateRequest.Method = "POST"; 123 AgentCreateRequest.Method = "POST";
106 AgentCreateRequest.ContentType = "application/json"; 124 AgentCreateRequest.ContentType = "application/json";
107 AgentCreateRequest.Timeout = 10000; 125 AgentCreateRequest.Timeout = 10000;
@@ -134,7 +152,7 @@ namespace OpenSim.Services.Connectors.Simulation
134 AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send 152 AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send
135 os = AgentCreateRequest.GetRequestStream(); 153 os = AgentCreateRequest.GetRequestStream();
136 os.Write(buffer, 0, strBuffer.Length); //Send it 154 os.Write(buffer, 0, strBuffer.Length); //Send it
137 m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Posted CreateAgent request to remote sim {0}, region {1}, x={2} y={3}", 155 m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Posted CreateAgent request to remote sim {0}, region {1}, x={2} y={3}",
138 uri, destination.RegionName, destination.RegionLocX, destination.RegionLocY); 156 uri, destination.RegionName, destination.RegionLocX, destination.RegionLocY);
139 } 157 }
140 //catch (WebException ex) 158 //catch (WebException ex)
@@ -150,11 +168,18 @@ namespace OpenSim.Services.Connectors.Simulation
150 os.Close(); 168 os.Close();
151 } 169 }
152 170
171 return true;
172 }
173
174 protected string GetResponse(HttpWebRequest AgentCreateRequest, out string reason)
175 {
153 // Let's wait for the response 176 // Let's wait for the response
154 //m_log.Info("[REMOTE SIMULATION CONNECTOR]: Waiting for a reply after DoCreateChildAgentCall"); 177 //m_log.Info("[REMOTE SIMULATION CONNECTOR]: Waiting for a reply after DoCreateChildAgentCall");
178 reason = string.Empty;
155 179
156 WebResponse webResponse = null; 180 WebResponse webResponse = null;
157 StreamReader sr = null; 181 StreamReader sr = null;
182 string response = string.Empty;
158 try 183 try
159 { 184 {
160 webResponse = AgentCreateRequest.GetResponse(); 185 webResponse = AgentCreateRequest.GetResponse();
@@ -166,37 +191,15 @@ namespace OpenSim.Services.Connectors.Simulation
166 { 191 {
167 192
168 sr = new StreamReader(webResponse.GetResponseStream()); 193 sr = new StreamReader(webResponse.GetResponseStream());
169 string response = sr.ReadToEnd().Trim(); 194 response = sr.ReadToEnd().Trim();
170 m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: DoCreateChildAgentCall reply was {0} ", response); 195 m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: DoCreateChildAgentCall reply was {0} ", response);
171
172 if (!String.IsNullOrEmpty(response))
173 {
174 try
175 {
176 // we assume we got an OSDMap back
177 OSDMap r = Util.GetOSDMap(response);
178 bool success = r["success"].AsBoolean();
179 reason = r["reason"].AsString();
180 return success;
181 }
182 catch (NullReferenceException e)
183 {
184 m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", e.Message);
185
186 // check for old style response
187 if (response.ToLower().StartsWith("true"))
188 return true;
189
190 return false;
191 }
192 }
193 } 196 }
194 } 197 }
195 catch (WebException ex) 198 catch (WebException ex)
196 { 199 {
197 m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", ex.Message); 200 m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", ex.Message);
198 reason = "Destination did not reply"; 201 reason = "Destination did not reply";
199 return false; 202 return string.Empty;
200 } 203 }
201 finally 204 finally
202 { 205 {
@@ -204,7 +207,33 @@ namespace OpenSim.Services.Connectors.Simulation
204 sr.Close(); 207 sr.Close();
205 } 208 }
206 209
207 return true; 210 return response;
211 }
212
213 protected void UnpackResponse(string response, out bool result, out string reason)
214 {
215 result = true;
216 reason = string.Empty;
217 if (!String.IsNullOrEmpty(response))
218 {
219 try
220 {
221 // we assume we got an OSDMap back
222 OSDMap r = Util.GetOSDMap(response);
223 result = r["success"].AsBoolean();
224 reason = r["reason"].AsString();
225 }
226 catch (NullReferenceException e)
227 {
228 m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", e.Message);
229
230 // check for old style response
231 if (response.ToLower().StartsWith("true"))
232 result = true;
233
234 result = false;
235 }
236 }
208 } 237 }
209 238
210 protected virtual OSDMap PackCreateAgentArguments(AgentCircuitData aCircuit, GridRegion destination, uint flags) 239 protected virtual OSDMap PackCreateAgentArguments(AgentCircuitData aCircuit, GridRegion destination, uint flags)