diff options
author | Diva Canto | 2010-01-28 19:19:42 -0800 |
---|---|---|
committer | Diva Canto | 2010-01-28 19:19:42 -0800 |
commit | 00f7d622cbc2c2e61d2efaacd8275da3f9821d8b (patch) | |
tree | 1bfc6dd3ac2a93443bc75baa03ceefba4cfacc1e /OpenSim/Services/Connectors | |
parent | Added ExternalName config on Gatekeeper. (diff) | |
download | opensim-SC-00f7d622cbc2c2e61d2efaacd8275da3f9821d8b.zip opensim-SC-00f7d622cbc2c2e61d2efaacd8275da3f9821d8b.tar.gz opensim-SC-00f7d622cbc2c2e61d2efaacd8275da3f9821d8b.tar.bz2 opensim-SC-00f7d622cbc2c2e61d2efaacd8275da3f9821d8b.tar.xz |
HG 1.5 is in place. Tested in standalone only.
Diffstat (limited to 'OpenSim/Services/Connectors')
4 files changed, 392 insertions, 237 deletions
diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs index 5ad1af2..608228d 100644 --- a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs | |||
@@ -241,95 +241,5 @@ namespace OpenSim.Services.Connectors.Hypergrid | |||
241 | return null; | 241 | return null; |
242 | } | 242 | } |
243 | 243 | ||
244 | public GridRegion GetHomeRegion(GridRegion gatekeeper, UUID userID, out Vector3 position, out Vector3 lookAt) | ||
245 | { | ||
246 | position = Vector3.UnitY; lookAt = Vector3.UnitY; | ||
247 | |||
248 | Hashtable hash = new Hashtable(); | ||
249 | hash["userID"] = userID.ToString(); | ||
250 | |||
251 | IList paramList = new ArrayList(); | ||
252 | paramList.Add(hash); | ||
253 | |||
254 | XmlRpcRequest request = new XmlRpcRequest("get_home_region", paramList); | ||
255 | string uri = "http://" + gatekeeper.ExternalHostName + ":" + gatekeeper.HttpPort + "/"; | ||
256 | XmlRpcResponse response = null; | ||
257 | try | ||
258 | { | ||
259 | response = request.Send(uri, 10000); | ||
260 | } | ||
261 | catch (Exception e) | ||
262 | { | ||
263 | return null; | ||
264 | } | ||
265 | |||
266 | if (response.IsFault) | ||
267 | { | ||
268 | return null; | ||
269 | } | ||
270 | |||
271 | hash = (Hashtable)response.Value; | ||
272 | //foreach (Object o in hash) | ||
273 | // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); | ||
274 | try | ||
275 | { | ||
276 | bool success = false; | ||
277 | Boolean.TryParse((string)hash["result"], out success); | ||
278 | if (success) | ||
279 | { | ||
280 | GridRegion region = new GridRegion(); | ||
281 | |||
282 | UUID.TryParse((string)hash["uuid"], out region.RegionID); | ||
283 | //m_log.Debug(">> HERE, uuid: " + region.RegionID); | ||
284 | int n = 0; | ||
285 | if (hash["x"] != null) | ||
286 | { | ||
287 | Int32.TryParse((string)hash["x"], out n); | ||
288 | region.RegionLocX = n; | ||
289 | //m_log.Debug(">> HERE, x: " + region.RegionLocX); | ||
290 | } | ||
291 | if (hash["y"] != null) | ||
292 | { | ||
293 | Int32.TryParse((string)hash["y"], out n); | ||
294 | region.RegionLocY = n; | ||
295 | //m_log.Debug(">> HERE, y: " + region.RegionLocY); | ||
296 | } | ||
297 | if (hash["region_name"] != null) | ||
298 | { | ||
299 | region.RegionName = (string)hash["region_name"]; | ||
300 | //m_log.Debug(">> HERE, name: " + region.RegionName); | ||
301 | } | ||
302 | if (hash["hostname"] != null) | ||
303 | region.ExternalHostName = (string)hash["hostname"]; | ||
304 | if (hash["http_port"] != null) | ||
305 | { | ||
306 | uint p = 0; | ||
307 | UInt32.TryParse((string)hash["http_port"], out p); | ||
308 | region.HttpPort = p; | ||
309 | } | ||
310 | if (hash["internal_port"] != null) | ||
311 | { | ||
312 | int p = 0; | ||
313 | Int32.TryParse((string)hash["internal_port"], out p); | ||
314 | region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p); | ||
315 | } | ||
316 | if (hash["position"] != null) | ||
317 | Vector3.TryParse((string)hash["position"], out position); | ||
318 | if (hash["lookAt"] != null) | ||
319 | Vector3.TryParse((string)hash["lookAt"], out lookAt); | ||
320 | |||
321 | // Successful return | ||
322 | return region; | ||
323 | } | ||
324 | |||
325 | } | ||
326 | catch (Exception e) | ||
327 | { | ||
328 | return null; | ||
329 | } | ||
330 | |||
331 | return null; | ||
332 | |||
333 | } | ||
334 | } | 244 | } |
335 | } | 245 | } |
diff --git a/OpenSim/Services/Connectors/Hypergrid/HomeUsersSecurityServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HomeUsersSecurityServiceConnector.cs deleted file mode 100644 index 150690b..0000000 --- a/OpenSim/Services/Connectors/Hypergrid/HomeUsersSecurityServiceConnector.cs +++ /dev/null | |||
@@ -1,132 +0,0 @@ | |||
1 | using System; | ||
2 | using System.Collections; | ||
3 | using System.Collections.Generic; | ||
4 | using System.Net; | ||
5 | using System.Reflection; | ||
6 | |||
7 | using OpenSim.Services.Interfaces; | ||
8 | |||
9 | using OpenMetaverse; | ||
10 | using log4net; | ||
11 | using Nwc.XmlRpc; | ||
12 | using Nini.Config; | ||
13 | |||
14 | namespace OpenSim.Services.Connectors.Hypergrid | ||
15 | { | ||
16 | public class HomeUsersSecurityServiceConnector : IHomeUsersSecurityService | ||
17 | { | ||
18 | private static readonly ILog m_log = | ||
19 | LogManager.GetLogger( | ||
20 | MethodBase.GetCurrentMethod().DeclaringType); | ||
21 | |||
22 | string m_ServerURL; | ||
23 | public HomeUsersSecurityServiceConnector(string url) | ||
24 | { | ||
25 | m_ServerURL = url; | ||
26 | } | ||
27 | |||
28 | public HomeUsersSecurityServiceConnector(IConfigSource config) | ||
29 | { | ||
30 | } | ||
31 | |||
32 | public void SetEndPoint(UUID sessionID, IPEndPoint ep) | ||
33 | { | ||
34 | Hashtable hash = new Hashtable(); | ||
35 | hash["sessionID"] = sessionID.ToString(); | ||
36 | hash["ep_addr"] = ep.Address.ToString(); | ||
37 | hash["ep_port"] = ep.Port.ToString(); | ||
38 | |||
39 | Call("ep_set", hash); | ||
40 | } | ||
41 | |||
42 | public void RemoveEndPoint(UUID sessionID) | ||
43 | { | ||
44 | Hashtable hash = new Hashtable(); | ||
45 | hash["sessionID"] = sessionID.ToString(); | ||
46 | |||
47 | Call("ep_remove", hash); | ||
48 | } | ||
49 | |||
50 | public IPEndPoint GetEndPoint(UUID sessionID) | ||
51 | { | ||
52 | Hashtable hash = new Hashtable(); | ||
53 | hash["sessionID"] = sessionID.ToString(); | ||
54 | |||
55 | IList paramList = new ArrayList(); | ||
56 | paramList.Add(hash); | ||
57 | |||
58 | XmlRpcRequest request = new XmlRpcRequest("ep_get", paramList); | ||
59 | //m_log.Debug("[HGrid]: Linking to " + uri); | ||
60 | XmlRpcResponse response = null; | ||
61 | try | ||
62 | { | ||
63 | response = request.Send(m_ServerURL, 10000); | ||
64 | } | ||
65 | catch (Exception e) | ||
66 | { | ||
67 | m_log.Debug("[HGrid]: Exception " + e.Message); | ||
68 | return null; | ||
69 | } | ||
70 | |||
71 | if (response.IsFault) | ||
72 | { | ||
73 | m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString); | ||
74 | return null; | ||
75 | } | ||
76 | |||
77 | hash = (Hashtable)response.Value; | ||
78 | //foreach (Object o in hash) | ||
79 | // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); | ||
80 | try | ||
81 | { | ||
82 | bool success = false; | ||
83 | Boolean.TryParse((string)hash["result"], out success); | ||
84 | if (success) | ||
85 | { | ||
86 | IPEndPoint ep = null; | ||
87 | int port = 0; | ||
88 | if (hash["ep_port"] != null) | ||
89 | Int32.TryParse((string)hash["ep_port"], out port); | ||
90 | if (hash["ep_addr"] != null) | ||
91 | ep = new IPEndPoint(IPAddress.Parse((string)hash["ep_addr"]), port); | ||
92 | |||
93 | return ep; | ||
94 | } | ||
95 | |||
96 | } | ||
97 | catch (Exception e) | ||
98 | { | ||
99 | m_log.Error("[HGrid]: Got exception while parsing GetEndPoint response " + e.StackTrace); | ||
100 | return null; | ||
101 | } | ||
102 | |||
103 | return null; | ||
104 | } | ||
105 | |||
106 | private void Call(string method, Hashtable hash) | ||
107 | { | ||
108 | IList paramList = new ArrayList(); | ||
109 | paramList.Add(hash); | ||
110 | |||
111 | XmlRpcRequest request = new XmlRpcRequest(method, paramList); | ||
112 | XmlRpcResponse response = null; | ||
113 | try | ||
114 | { | ||
115 | response = request.Send(m_ServerURL, 10000); | ||
116 | } | ||
117 | catch (Exception e) | ||
118 | { | ||
119 | m_log.Debug("[HGrid]: Exception " + e.Message); | ||
120 | return ; | ||
121 | } | ||
122 | |||
123 | if (response.IsFault) | ||
124 | { | ||
125 | m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString); | ||
126 | return ; | ||
127 | } | ||
128 | |||
129 | } | ||
130 | |||
131 | } | ||
132 | } | ||
diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs new file mode 100644 index 0000000..83d3449 --- /dev/null +++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs | |||
@@ -0,0 +1,370 @@ | |||
1 | using System; | ||
2 | using System.Collections; | ||
3 | using System.Collections.Generic; | ||
4 | using System.IO; | ||
5 | using System.Net; | ||
6 | using System.Reflection; | ||
7 | using System.Text; | ||
8 | |||
9 | using OpenSim.Framework; | ||
10 | using OpenSim.Services.Interfaces; | ||
11 | using OpenSim.Services.Connectors.Simulation; | ||
12 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
13 | |||
14 | using OpenMetaverse; | ||
15 | using OpenMetaverse.StructuredData; | ||
16 | using log4net; | ||
17 | using Nwc.XmlRpc; | ||
18 | using Nini.Config; | ||
19 | |||
20 | namespace OpenSim.Services.Connectors.Hypergrid | ||
21 | { | ||
22 | public class UserAgentServiceConnector : IUserAgentService | ||
23 | { | ||
24 | private static readonly ILog m_log = | ||
25 | LogManager.GetLogger( | ||
26 | MethodBase.GetCurrentMethod().DeclaringType); | ||
27 | |||
28 | string m_ServerURL; | ||
29 | public UserAgentServiceConnector(string url) | ||
30 | { | ||
31 | m_ServerURL = url; | ||
32 | } | ||
33 | |||
34 | public UserAgentServiceConnector(IConfigSource config) | ||
35 | { | ||
36 | } | ||
37 | |||
38 | public bool LoginAgentToGrid(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination, out string reason) | ||
39 | { | ||
40 | reason = String.Empty; | ||
41 | |||
42 | if (destination == null) | ||
43 | { | ||
44 | reason = "Destination is null"; | ||
45 | m_log.Debug("[USER AGENT CONNECTOR]: Given destination is null"); | ||
46 | return false; | ||
47 | } | ||
48 | |||
49 | string uri = m_ServerURL + "/homeagent/" + aCircuit.AgentID + "/"; | ||
50 | |||
51 | Console.WriteLine(" >>> LoginAgentToGrid <<< " + uri); | ||
52 | |||
53 | HttpWebRequest AgentCreateRequest = (HttpWebRequest)WebRequest.Create(uri); | ||
54 | AgentCreateRequest.Method = "POST"; | ||
55 | AgentCreateRequest.ContentType = "application/json"; | ||
56 | AgentCreateRequest.Timeout = 10000; | ||
57 | //AgentCreateRequest.KeepAlive = false; | ||
58 | //AgentCreateRequest.Headers.Add("Authorization", authKey); | ||
59 | |||
60 | // Fill it in | ||
61 | OSDMap args = PackCreateAgentArguments(aCircuit, gatekeeper, destination); | ||
62 | |||
63 | string strBuffer = ""; | ||
64 | byte[] buffer = new byte[1]; | ||
65 | try | ||
66 | { | ||
67 | strBuffer = OSDParser.SerializeJsonString(args); | ||
68 | Encoding str = Util.UTF8; | ||
69 | buffer = str.GetBytes(strBuffer); | ||
70 | |||
71 | } | ||
72 | catch (Exception e) | ||
73 | { | ||
74 | m_log.WarnFormat("[USER AGENT CONNECTOR]: Exception thrown on serialization of ChildCreate: {0}", e.Message); | ||
75 | // ignore. buffer will be empty, caller should check. | ||
76 | } | ||
77 | |||
78 | Stream os = null; | ||
79 | try | ||
80 | { // send the Post | ||
81 | AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send | ||
82 | os = AgentCreateRequest.GetRequestStream(); | ||
83 | os.Write(buffer, 0, strBuffer.Length); //Send it | ||
84 | m_log.InfoFormat("[USER AGENT CONNECTOR]: Posted CreateAgent request to remote sim {0}, region {1}, x={2} y={3}", | ||
85 | uri, destination.RegionName, destination.RegionLocX, destination.RegionLocY); | ||
86 | } | ||
87 | //catch (WebException ex) | ||
88 | catch | ||
89 | { | ||
90 | //m_log.InfoFormat("[USER AGENT CONNECTOR]: Bad send on ChildAgentUpdate {0}", ex.Message); | ||
91 | reason = "cannot contact remote region"; | ||
92 | return false; | ||
93 | } | ||
94 | finally | ||
95 | { | ||
96 | if (os != null) | ||
97 | os.Close(); | ||
98 | } | ||
99 | |||
100 | // Let's wait for the response | ||
101 | //m_log.Info("[USER AGENT CONNECTOR]: Waiting for a reply after DoCreateChildAgentCall"); | ||
102 | |||
103 | WebResponse webResponse = null; | ||
104 | StreamReader sr = null; | ||
105 | try | ||
106 | { | ||
107 | webResponse = AgentCreateRequest.GetResponse(); | ||
108 | if (webResponse == null) | ||
109 | { | ||
110 | m_log.Info("[USER AGENT CONNECTOR]: Null reply on DoCreateChildAgentCall post"); | ||
111 | } | ||
112 | else | ||
113 | { | ||
114 | |||
115 | sr = new StreamReader(webResponse.GetResponseStream()); | ||
116 | string response = sr.ReadToEnd().Trim(); | ||
117 | m_log.InfoFormat("[USER AGENT CONNECTOR]: DoCreateChildAgentCall reply was {0} ", response); | ||
118 | |||
119 | if (!String.IsNullOrEmpty(response)) | ||
120 | { | ||
121 | try | ||
122 | { | ||
123 | // we assume we got an OSDMap back | ||
124 | OSDMap r = Util.GetOSDMap(response); | ||
125 | bool success = r["success"].AsBoolean(); | ||
126 | reason = r["reason"].AsString(); | ||
127 | return success; | ||
128 | } | ||
129 | catch (NullReferenceException e) | ||
130 | { | ||
131 | m_log.InfoFormat("[USER AGENT CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", e.Message); | ||
132 | |||
133 | // check for old style response | ||
134 | if (response.ToLower().StartsWith("true")) | ||
135 | return true; | ||
136 | |||
137 | return false; | ||
138 | } | ||
139 | } | ||
140 | } | ||
141 | } | ||
142 | catch (WebException ex) | ||
143 | { | ||
144 | m_log.InfoFormat("[USER AGENT CONNECTOR]: exception on reply of DoCreateChildAgentCall {0}", ex.Message); | ||
145 | reason = "Destination did not reply"; | ||
146 | return false; | ||
147 | } | ||
148 | finally | ||
149 | { | ||
150 | if (sr != null) | ||
151 | sr.Close(); | ||
152 | } | ||
153 | |||
154 | return true; | ||
155 | |||
156 | } | ||
157 | |||
158 | protected OSDMap PackCreateAgentArguments(AgentCircuitData aCircuit, GridRegion gatekeeper, GridRegion destination) | ||
159 | { | ||
160 | OSDMap args = null; | ||
161 | try | ||
162 | { | ||
163 | args = aCircuit.PackAgentCircuitData(); | ||
164 | } | ||
165 | catch (Exception e) | ||
166 | { | ||
167 | m_log.Debug("[USER AGENT CONNECTOR]: PackAgentCircuitData failed with exception: " + e.Message); | ||
168 | } | ||
169 | // Add the input arguments | ||
170 | args["gatekeeper_host"] = OSD.FromString(gatekeeper.ExternalHostName); | ||
171 | args["gatekeeper_port"] = OSD.FromString(gatekeeper.HttpPort.ToString()); | ||
172 | args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString()); | ||
173 | args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString()); | ||
174 | args["destination_name"] = OSD.FromString(destination.RegionName); | ||
175 | args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString()); | ||
176 | |||
177 | return args; | ||
178 | } | ||
179 | |||
180 | public GridRegion GetHomeRegion(UUID userID, out Vector3 position, out Vector3 lookAt) | ||
181 | { | ||
182 | position = Vector3.UnitY; lookAt = Vector3.UnitY; | ||
183 | |||
184 | Hashtable hash = new Hashtable(); | ||
185 | hash["userID"] = userID.ToString(); | ||
186 | |||
187 | IList paramList = new ArrayList(); | ||
188 | paramList.Add(hash); | ||
189 | |||
190 | XmlRpcRequest request = new XmlRpcRequest("get_home_region", paramList); | ||
191 | XmlRpcResponse response = null; | ||
192 | try | ||
193 | { | ||
194 | response = request.Send(m_ServerURL, 10000); | ||
195 | } | ||
196 | catch (Exception e) | ||
197 | { | ||
198 | return null; | ||
199 | } | ||
200 | |||
201 | if (response.IsFault) | ||
202 | { | ||
203 | return null; | ||
204 | } | ||
205 | |||
206 | hash = (Hashtable)response.Value; | ||
207 | //foreach (Object o in hash) | ||
208 | // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); | ||
209 | try | ||
210 | { | ||
211 | bool success = false; | ||
212 | Boolean.TryParse((string)hash["result"], out success); | ||
213 | if (success) | ||
214 | { | ||
215 | GridRegion region = new GridRegion(); | ||
216 | |||
217 | UUID.TryParse((string)hash["uuid"], out region.RegionID); | ||
218 | //m_log.Debug(">> HERE, uuid: " + region.RegionID); | ||
219 | int n = 0; | ||
220 | if (hash["x"] != null) | ||
221 | { | ||
222 | Int32.TryParse((string)hash["x"], out n); | ||
223 | region.RegionLocX = n; | ||
224 | //m_log.Debug(">> HERE, x: " + region.RegionLocX); | ||
225 | } | ||
226 | if (hash["y"] != null) | ||
227 | { | ||
228 | Int32.TryParse((string)hash["y"], out n); | ||
229 | region.RegionLocY = n; | ||
230 | //m_log.Debug(">> HERE, y: " + region.RegionLocY); | ||
231 | } | ||
232 | if (hash["region_name"] != null) | ||
233 | { | ||
234 | region.RegionName = (string)hash["region_name"]; | ||
235 | //m_log.Debug(">> HERE, name: " + region.RegionName); | ||
236 | } | ||
237 | if (hash["hostname"] != null) | ||
238 | region.ExternalHostName = (string)hash["hostname"]; | ||
239 | if (hash["http_port"] != null) | ||
240 | { | ||
241 | uint p = 0; | ||
242 | UInt32.TryParse((string)hash["http_port"], out p); | ||
243 | region.HttpPort = p; | ||
244 | } | ||
245 | if (hash["internal_port"] != null) | ||
246 | { | ||
247 | int p = 0; | ||
248 | Int32.TryParse((string)hash["internal_port"], out p); | ||
249 | region.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), p); | ||
250 | } | ||
251 | if (hash["position"] != null) | ||
252 | Vector3.TryParse((string)hash["position"], out position); | ||
253 | if (hash["lookAt"] != null) | ||
254 | Vector3.TryParse((string)hash["lookAt"], out lookAt); | ||
255 | |||
256 | // Successful return | ||
257 | return region; | ||
258 | } | ||
259 | |||
260 | } | ||
261 | catch (Exception e) | ||
262 | { | ||
263 | return null; | ||
264 | } | ||
265 | |||
266 | return null; | ||
267 | |||
268 | } | ||
269 | |||
270 | public bool AgentIsComingHome(UUID sessionID, string thisGridExternalName) | ||
271 | { | ||
272 | Hashtable hash = new Hashtable(); | ||
273 | hash["sessionID"] = sessionID.ToString(); | ||
274 | hash["externalName"] = thisGridExternalName; | ||
275 | |||
276 | IList paramList = new ArrayList(); | ||
277 | paramList.Add(hash); | ||
278 | |||
279 | XmlRpcRequest request = new XmlRpcRequest("agent_is_coming_home", paramList); | ||
280 | string reason = string.Empty; | ||
281 | return GetBoolResponse(request, out reason); | ||
282 | } | ||
283 | |||
284 | public bool VerifyAgent(UUID sessionID, string token) | ||
285 | { | ||
286 | Hashtable hash = new Hashtable(); | ||
287 | hash["sessionID"] = sessionID.ToString(); | ||
288 | hash["token"] = token; | ||
289 | |||
290 | IList paramList = new ArrayList(); | ||
291 | paramList.Add(hash); | ||
292 | |||
293 | XmlRpcRequest request = new XmlRpcRequest("verify_agent", paramList); | ||
294 | string reason = string.Empty; | ||
295 | return GetBoolResponse(request, out reason); | ||
296 | } | ||
297 | |||
298 | public bool VerifyClient(UUID sessionID, string token) | ||
299 | { | ||
300 | Hashtable hash = new Hashtable(); | ||
301 | hash["sessionID"] = sessionID.ToString(); | ||
302 | hash["token"] = token; | ||
303 | |||
304 | IList paramList = new ArrayList(); | ||
305 | paramList.Add(hash); | ||
306 | |||
307 | XmlRpcRequest request = new XmlRpcRequest("verify_client", paramList); | ||
308 | string reason = string.Empty; | ||
309 | return GetBoolResponse(request, out reason); | ||
310 | } | ||
311 | |||
312 | public void LogoutAgent(UUID userID, UUID sessionID) | ||
313 | { | ||
314 | Hashtable hash = new Hashtable(); | ||
315 | hash["sessionID"] = sessionID.ToString(); | ||
316 | hash["userID"] = userID.ToString(); | ||
317 | |||
318 | IList paramList = new ArrayList(); | ||
319 | paramList.Add(hash); | ||
320 | |||
321 | XmlRpcRequest request = new XmlRpcRequest("logout_agent", paramList); | ||
322 | string reason = string.Empty; | ||
323 | GetBoolResponse(request, out reason); | ||
324 | } | ||
325 | |||
326 | |||
327 | private bool GetBoolResponse(XmlRpcRequest request, out string reason) | ||
328 | { | ||
329 | //m_log.Debug("[HGrid]: Linking to " + uri); | ||
330 | XmlRpcResponse response = null; | ||
331 | try | ||
332 | { | ||
333 | response = request.Send(m_ServerURL, 10000); | ||
334 | } | ||
335 | catch (Exception e) | ||
336 | { | ||
337 | m_log.Debug("[HGrid]: Exception " + e.Message); | ||
338 | reason = "Exception: " + e.Message; | ||
339 | return false; | ||
340 | } | ||
341 | |||
342 | if (response.IsFault) | ||
343 | { | ||
344 | m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString); | ||
345 | reason = "XMLRPC Fault"; | ||
346 | return false; | ||
347 | } | ||
348 | |||
349 | Hashtable hash = (Hashtable)response.Value; | ||
350 | //foreach (Object o in hash) | ||
351 | // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); | ||
352 | try | ||
353 | { | ||
354 | bool success = false; | ||
355 | reason = string.Empty; | ||
356 | Boolean.TryParse((string)hash["result"], out success); | ||
357 | |||
358 | return success; | ||
359 | } | ||
360 | catch (Exception e) | ||
361 | { | ||
362 | m_log.Error("[HGrid]: Got exception while parsing GetEndPoint response " + e.StackTrace); | ||
363 | reason = "Exception: " + e.Message; | ||
364 | return false; | ||
365 | } | ||
366 | |||
367 | } | ||
368 | |||
369 | } | ||
370 | } | ||
diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs index 683fe79..e2ab179 100644 --- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs | |||
@@ -104,21 +104,7 @@ namespace OpenSim.Services.Connectors.Simulation | |||
104 | //AgentCreateRequest.Headers.Add("Authorization", authKey); | 104 | //AgentCreateRequest.Headers.Add("Authorization", authKey); |
105 | 105 | ||
106 | // Fill it in | 106 | // Fill it in |
107 | OSDMap args = null; | 107 | OSDMap args = PackCreateAgentArguments(aCircuit, destination, flags); |
108 | try | ||
109 | { | ||
110 | args = aCircuit.PackAgentCircuitData(); | ||
111 | } | ||
112 | catch (Exception e) | ||
113 | { | ||
114 | m_log.Debug("[REMOTE SIMULATION CONNECTOR]: PackAgentCircuitData failed with exception: " + e.Message); | ||
115 | } | ||
116 | // Add the input arguments | ||
117 | args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString()); | ||
118 | args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString()); | ||
119 | args["destination_name"] = OSD.FromString(destination.RegionName); | ||
120 | args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString()); | ||
121 | args["teleport_flags"] = OSD.FromString(flags.ToString()); | ||
122 | 108 | ||
123 | string strBuffer = ""; | 109 | string strBuffer = ""; |
124 | byte[] buffer = new byte[1]; | 110 | byte[] buffer = new byte[1]; |
@@ -214,6 +200,27 @@ namespace OpenSim.Services.Connectors.Simulation | |||
214 | return true; | 200 | return true; |
215 | } | 201 | } |
216 | 202 | ||
203 | protected virtual OSDMap PackCreateAgentArguments(AgentCircuitData aCircuit, GridRegion destination, uint flags) | ||
204 | { | ||
205 | OSDMap args = null; | ||
206 | try | ||
207 | { | ||
208 | args = aCircuit.PackAgentCircuitData(); | ||
209 | } | ||
210 | catch (Exception e) | ||
211 | { | ||
212 | m_log.Debug("[REMOTE SIMULATION CONNECTOR]: PackAgentCircuitData failed with exception: " + e.Message); | ||
213 | } | ||
214 | // Add the input arguments | ||
215 | args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString()); | ||
216 | args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString()); | ||
217 | args["destination_name"] = OSD.FromString(destination.RegionName); | ||
218 | args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString()); | ||
219 | args["teleport_flags"] = OSD.FromString(flags.ToString()); | ||
220 | |||
221 | return args; | ||
222 | } | ||
223 | |||
217 | public bool UpdateAgent(GridRegion destination, AgentData data) | 224 | public bool UpdateAgent(GridRegion destination, AgentData data) |
218 | { | 225 | { |
219 | return UpdateAgent(destination, (IAgentData)data); | 226 | return UpdateAgent(destination, (IAgentData)data); |