diff options
author | Adam Frisby | 2007-07-11 08:10:25 +0000 |
---|---|---|
committer | Adam Frisby | 2007-07-11 08:10:25 +0000 |
commit | e2ff441e31328e60c8bb1d4bb32fa4ac64f91978 (patch) | |
tree | 8405b6cef57b66a58f31a24c859846085d0b81f7 /OpenSim/Region/Communications/OGS1 | |
parent | * Wiping trunk in prep for Sugilite (diff) | |
parent | * Applying dalien's patches from bug#177 and #179 (diff) | |
download | opensim-SC-e2ff441e31328e60c8bb1d4bb32fa4ac64f91978.zip opensim-SC-e2ff441e31328e60c8bb1d4bb32fa4ac64f91978.tar.gz opensim-SC-e2ff441e31328e60c8bb1d4bb32fa4ac64f91978.tar.bz2 opensim-SC-e2ff441e31328e60c8bb1d4bb32fa4ac64f91978.tar.xz |
* Bringing Sugilite in to trunk
Diffstat (limited to '')
5 files changed, 603 insertions, 0 deletions
diff --git a/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs b/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs new file mode 100644 index 0000000..cc05845 --- /dev/null +++ b/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs | |||
@@ -0,0 +1,18 @@ | |||
1 | using OpenSim.Framework.Communications; | ||
2 | using OpenSim.Framework.Types; | ||
3 | using OpenSim.Framework.Servers; | ||
4 | |||
5 | namespace OpenSim.Region.Communications.OGS1 | ||
6 | { | ||
7 | public class CommunicationsOGS1 : CommunicationsManager | ||
8 | { | ||
9 | |||
10 | public CommunicationsOGS1(NetworkServersInfo serversInfo, BaseHttpServer httpServer ) :base(serversInfo, httpServer) | ||
11 | { | ||
12 | OGS1GridServices gridInterComms = new OGS1GridServices(serversInfo, httpServer); | ||
13 | GridServer = gridInterComms; | ||
14 | InterRegion = gridInterComms; | ||
15 | UserServer = new OGS1UserServices(this); | ||
16 | } | ||
17 | } | ||
18 | } | ||
diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs new file mode 100644 index 0000000..66c1739 --- /dev/null +++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs | |||
@@ -0,0 +1,378 @@ | |||
1 | using System; | ||
2 | using System.Collections; | ||
3 | using System.Collections.Generic; | ||
4 | using System.Net; | ||
5 | using System.Runtime.Remoting; | ||
6 | using System.Runtime.Remoting.Channels; | ||
7 | using System.Runtime.Remoting.Channels.Tcp; | ||
8 | using libsecondlife; | ||
9 | using Nwc.XmlRpc; | ||
10 | using OpenSim.Framework; | ||
11 | using OpenSim.Framework.Communications; | ||
12 | using OpenSim.Framework.Console; | ||
13 | using OpenSim.Framework.Servers; | ||
14 | using OpenSim.Framework.Types; | ||
15 | |||
16 | namespace OpenSim.Region.Communications.OGS1 | ||
17 | { | ||
18 | public class OGS1GridServices : IGridServices, IInterRegionCommunications | ||
19 | { | ||
20 | public Dictionary<ulong, RegionCommsListener> listeners = new Dictionary<ulong, RegionCommsListener>(); | ||
21 | protected Dictionary<ulong, RegionInfo> regions = new Dictionary<ulong, RegionInfo>(); | ||
22 | |||
23 | public BaseHttpServer httpListener; | ||
24 | public NetworkServersInfo serversInfo; | ||
25 | public BaseHttpServer httpServer; | ||
26 | |||
27 | public OGS1GridServices(NetworkServersInfo servers_info, BaseHttpServer httpServe) | ||
28 | { | ||
29 | serversInfo = servers_info; | ||
30 | httpServer = httpServe; | ||
31 | httpServer.AddXmlRPCHandler("expect_user", this.ExpectUser); | ||
32 | this.StartRemoting(); | ||
33 | } | ||
34 | |||
35 | public RegionCommsListener RegisterRegion(RegionInfo regionInfo) | ||
36 | { | ||
37 | if (!this.regions.ContainsKey((uint)regionInfo.RegionHandle)) | ||
38 | { | ||
39 | this.regions.Add(regionInfo.RegionHandle, regionInfo); | ||
40 | } | ||
41 | |||
42 | Hashtable GridParams = new Hashtable(); | ||
43 | |||
44 | |||
45 | // Login / Authentication | ||
46 | |||
47 | GridParams["authkey"] = serversInfo.GridSendKey; | ||
48 | GridParams["UUID"] = regionInfo.SimUUID.ToStringHyphenated(); | ||
49 | GridParams["sim_ip"] = regionInfo.ExternalHostName; | ||
50 | GridParams["sim_port"] = regionInfo.InternalEndPoint.Port.ToString(); | ||
51 | GridParams["region_locx"] = regionInfo.RegionLocX.ToString(); | ||
52 | GridParams["region_locy"] = regionInfo.RegionLocY.ToString(); | ||
53 | GridParams["sim_name"] = regionInfo.RegionName; | ||
54 | GridParams["http_port"] = serversInfo.HttpListenerPort.ToString(); | ||
55 | GridParams["remoting_port"] = serversInfo.RemotingListenerPort.ToString(); | ||
56 | GridParams["map-image-id"] = regionInfo.estateSettings.terrainImageID.ToStringHyphenated(); | ||
57 | |||
58 | // Package into an XMLRPC Request | ||
59 | ArrayList SendParams = new ArrayList(); | ||
60 | SendParams.Add(GridParams); | ||
61 | |||
62 | // Send Request | ||
63 | XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams); | ||
64 | XmlRpcResponse GridResp = GridReq.Send(serversInfo.GridURL, 3000); | ||
65 | Hashtable GridRespData = (Hashtable)GridResp.Value; | ||
66 | |||
67 | Hashtable griddatahash = GridRespData; | ||
68 | |||
69 | // Process Response | ||
70 | if (GridRespData.ContainsKey("error")) | ||
71 | { | ||
72 | string errorstring = (string)GridRespData["error"]; | ||
73 | MainLog.Instance.Error("Unable to connect to grid: " + errorstring); | ||
74 | return null; | ||
75 | } | ||
76 | |||
77 | /* if (!this.listeners.ContainsKey(regionInfo.RegionHandle)) | ||
78 | { | ||
79 | MainLog.Instance.Verbose("OGS1 - Registering new HTTP listener on port " + regionInfo.InternalEndPoint.Port.ToString()); | ||
80 | // initialised = true; | ||
81 | httpListener = new BaseHttpServer( regionInfo.InternalEndPoint.Port ); | ||
82 | httpListener.AddXmlRPCHandler("expect_user", this.ExpectUser); | ||
83 | httpListener.Start(); | ||
84 | }*/ | ||
85 | |||
86 | // Initialise the background listeners | ||
87 | RegionCommsListener regListener = new RegionCommsListener(); | ||
88 | if (this.listeners.ContainsKey(regionInfo.RegionHandle)) | ||
89 | { | ||
90 | this.listeners.Add(regionInfo.RegionHandle, regListener); | ||
91 | } | ||
92 | else | ||
93 | { | ||
94 | listeners[regionInfo.RegionHandle] = regListener; | ||
95 | } | ||
96 | |||
97 | return regListener; | ||
98 | } | ||
99 | |||
100 | public List<RegionInfo> RequestNeighbours(RegionInfo regionInfo) | ||
101 | { | ||
102 | |||
103 | Hashtable respData = MapBlockQuery((int)regionInfo.RegionLocX - 1, (int)regionInfo.RegionLocY - 1, (int)regionInfo.RegionLocX + 1, (int)regionInfo.RegionLocY + 1); | ||
104 | |||
105 | List<RegionInfo> neighbours = new List<RegionInfo>(); | ||
106 | |||
107 | foreach (ArrayList a in respData.Values) | ||
108 | { | ||
109 | foreach (Hashtable n in a) | ||
110 | { | ||
111 | uint regX = Convert.ToUInt32(n["x"]); | ||
112 | uint regY = Convert.ToUInt32(n["y"]); | ||
113 | if ((regionInfo.RegionLocX != regX) || (regionInfo.RegionLocY != regY)) | ||
114 | { | ||
115 | string internalIpStr = (string)n["sim_ip"]; | ||
116 | uint port = Convert.ToUInt32(n["sim_port"]); | ||
117 | string externalUri = (string)n["sim_uri"]; | ||
118 | |||
119 | IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int)port); | ||
120 | string neighbourExternalUri = externalUri; | ||
121 | RegionInfo neighbour = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr); | ||
122 | |||
123 | //OGS1 | ||
124 | //neighbour.RegionHandle = (ulong)n["regionhandle"]; is now calculated locally | ||
125 | |||
126 | neighbour.RegionName = (string)n["name"]; | ||
127 | |||
128 | //OGS1+ | ||
129 | neighbour.SimUUID = (string)n["uuid"]; | ||
130 | |||
131 | neighbours.Add(neighbour); | ||
132 | } | ||
133 | } | ||
134 | } | ||
135 | |||
136 | return neighbours; | ||
137 | } | ||
138 | |||
139 | public RegionInfo RequestNeighbourInfo(ulong regionHandle) | ||
140 | { | ||
141 | if (this.regions.ContainsKey(regionHandle)) | ||
142 | { | ||
143 | return this.regions[regionHandle]; | ||
144 | } | ||
145 | //TODO not a region in this instance so ask remote grid server | ||
146 | |||
147 | Hashtable requestData = new Hashtable(); | ||
148 | requestData["region_handle"] = regionHandle.ToString(); | ||
149 | requestData["authkey"] = this.serversInfo.GridSendKey; | ||
150 | ArrayList SendParams = new ArrayList(); | ||
151 | SendParams.Add(requestData); | ||
152 | XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); | ||
153 | XmlRpcResponse GridResp = GridReq.Send(this.serversInfo.GridURL, 3000); | ||
154 | |||
155 | Hashtable responseData = (Hashtable)GridResp.Value; | ||
156 | |||
157 | if (responseData.ContainsKey("error")) | ||
158 | { | ||
159 | Console.WriteLine("error received from grid server" + responseData["error"]); | ||
160 | return null; | ||
161 | } | ||
162 | |||
163 | uint regX = Convert.ToUInt32((string)responseData["region_locx"]); | ||
164 | uint regY = Convert.ToUInt32((string)responseData["region_locy"]); | ||
165 | string internalIpStr = (string)responseData["sim_ip"]; | ||
166 | uint port = Convert.ToUInt32(responseData["sim_port"]); | ||
167 | string externalUri = (string)responseData["sim_uri"]; | ||
168 | |||
169 | IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int)port); | ||
170 | string neighbourExternalUri = externalUri; | ||
171 | RegionInfo regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr); | ||
172 | |||
173 | regionInfo.RemotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); | ||
174 | regionInfo.RemotingAddress = internalIpStr; | ||
175 | |||
176 | regionInfo.SimUUID = new LLUUID((string)responseData["region_UUID"]); | ||
177 | regionInfo.RegionName = (string)responseData["region_name"]; | ||
178 | |||
179 | return regionInfo; | ||
180 | } | ||
181 | |||
182 | public List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY) | ||
183 | { | ||
184 | Hashtable respData = MapBlockQuery(minX, minY, maxX, maxY); | ||
185 | |||
186 | List<MapBlockData> neighbours = new List<MapBlockData>(); | ||
187 | |||
188 | foreach (ArrayList a in respData.Values) | ||
189 | { | ||
190 | foreach (Hashtable n in a) | ||
191 | { | ||
192 | MapBlockData neighbour = new MapBlockData(); | ||
193 | |||
194 | neighbour.X = Convert.ToUInt16(n["x"]); | ||
195 | neighbour.Y = Convert.ToUInt16(n["y"]); | ||
196 | |||
197 | neighbour.Name = (string)n["name"]; | ||
198 | neighbour.Access = Convert.ToByte(n["access"]); | ||
199 | neighbour.RegionFlags = Convert.ToUInt32(n["region-flags"]); | ||
200 | neighbour.WaterHeight = Convert.ToByte(n["water-height"]); | ||
201 | neighbour.MapImageId = new LLUUID((string)n["map-image-id"]); | ||
202 | |||
203 | neighbours.Add(neighbour); | ||
204 | } | ||
205 | } | ||
206 | |||
207 | return neighbours; | ||
208 | } | ||
209 | |||
210 | /// <summary> | ||
211 | /// Performs a XML-RPC query against the grid server returning mapblock information in the specified coordinates | ||
212 | /// </summary> | ||
213 | /// <remarks>REDUNDANT - OGS1 is to be phased out in favour of OGS2</remarks> | ||
214 | /// <param name="minX">Minimum X value</param> | ||
215 | /// <param name="minY">Minimum Y value</param> | ||
216 | /// <param name="maxX">Maximum X value</param> | ||
217 | /// <param name="maxY">Maximum Y value</param> | ||
218 | /// <returns>Hashtable of hashtables containing map data elements</returns> | ||
219 | private Hashtable MapBlockQuery(int minX, int minY, int maxX, int maxY) | ||
220 | { | ||
221 | Hashtable param = new Hashtable(); | ||
222 | param["xmin"] = minX; | ||
223 | param["ymin"] = minY; | ||
224 | param["xmax"] = maxX; | ||
225 | param["ymax"] = maxY; | ||
226 | IList parameters = new ArrayList(); | ||
227 | parameters.Add(param); | ||
228 | XmlRpcRequest req = new XmlRpcRequest("map_block", parameters); | ||
229 | XmlRpcResponse resp = req.Send(serversInfo.GridURL, 3000); | ||
230 | Hashtable respData = (Hashtable)resp.Value; | ||
231 | return respData; | ||
232 | } | ||
233 | |||
234 | // Grid Request Processing | ||
235 | public XmlRpcResponse ExpectUser(XmlRpcRequest request) | ||
236 | { | ||
237 | Console.WriteLine("Expecting User..."); | ||
238 | Hashtable requestData = (Hashtable)request.Params[0]; | ||
239 | AgentCircuitData agentData = new AgentCircuitData(); | ||
240 | agentData.SessionID = new LLUUID((string)requestData["session_id"]); | ||
241 | agentData.SecureSessionID = new LLUUID((string)requestData["secure_session_id"]); | ||
242 | agentData.firstname = (string)requestData["firstname"]; | ||
243 | agentData.lastname = (string)requestData["lastname"]; | ||
244 | agentData.AgentID = new LLUUID((string)requestData["agent_id"]); | ||
245 | agentData.circuitcode = Convert.ToUInt32(requestData["circuit_code"]); | ||
246 | if (requestData.ContainsKey("child_agent") && requestData["child_agent"].Equals("1")) | ||
247 | { | ||
248 | agentData.child = true; | ||
249 | } | ||
250 | else | ||
251 | { | ||
252 | agentData.startpos = new LLVector3(Convert.ToUInt32(requestData["startpos_x"]), Convert.ToUInt32(requestData["startpos_y"]), Convert.ToUInt32(requestData["startpos_z"])); | ||
253 | agentData.child = false; | ||
254 | |||
255 | } | ||
256 | |||
257 | if (listeners.ContainsKey(Convert.ToUInt64((string)requestData["regionhandle"]))) | ||
258 | { | ||
259 | this.listeners[Convert.ToUInt64((string)requestData["regionhandle"])].TriggerExpectUser(Convert.ToUInt64((string)requestData["regionhandle"]), agentData); | ||
260 | } | ||
261 | else | ||
262 | { | ||
263 | MainLog.Instance.Error("ExpectUser() - Unknown region " + ((ulong)requestData["regionhandle"]).ToString()); | ||
264 | } | ||
265 | |||
266 | MainLog.Instance.Verbose("ExpectUser() - Welcoming new user..."); | ||
267 | |||
268 | return new XmlRpcResponse(); | ||
269 | } | ||
270 | |||
271 | #region InterRegion Comms | ||
272 | private void StartRemoting() | ||
273 | { | ||
274 | TcpChannel ch = new TcpChannel(this.serversInfo.RemotingListenerPort); | ||
275 | ChannelServices.RegisterChannel(ch, true); | ||
276 | |||
277 | WellKnownServiceTypeEntry wellType = new WellKnownServiceTypeEntry(typeof(OGS1InterRegionRemoting), "InterRegions", WellKnownObjectMode.Singleton); | ||
278 | RemotingConfiguration.RegisterWellKnownServiceType(wellType); | ||
279 | InterRegionSingleton.Instance.OnArrival += this.IncomingArrival; | ||
280 | InterRegionSingleton.Instance.OnChildAgent += this.IncomingChildAgent; | ||
281 | } | ||
282 | |||
283 | #region Methods called by regions in this instance | ||
284 | public bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData) | ||
285 | { | ||
286 | if (this.listeners.ContainsKey(regionHandle)) | ||
287 | { | ||
288 | this.listeners[regionHandle].TriggerExpectUser(regionHandle, agentData); | ||
289 | return true; | ||
290 | } | ||
291 | RegionInfo regInfo = this.RequestNeighbourInfo(regionHandle); | ||
292 | if (regInfo != null) | ||
293 | { | ||
294 | //don't want to be creating a new link to the remote instance every time like we are here | ||
295 | bool retValue = false; | ||
296 | |||
297 | |||
298 | OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( | ||
299 | typeof(OGS1InterRegionRemoting), | ||
300 | "tcp://"+ regInfo.RemotingAddress+":"+regInfo.RemotingPort+"/InterRegions"); | ||
301 | if (remObject != null) | ||
302 | { | ||
303 | |||
304 | retValue = remObject.InformRegionOfChildAgent(regionHandle, agentData); | ||
305 | } | ||
306 | else | ||
307 | { | ||
308 | Console.WriteLine("remoting object not found"); | ||
309 | } | ||
310 | remObject = null; | ||
311 | |||
312 | |||
313 | return retValue; | ||
314 | } | ||
315 | |||
316 | return false; | ||
317 | } | ||
318 | |||
319 | public bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position) | ||
320 | { | ||
321 | if (this.listeners.ContainsKey(regionHandle)) | ||
322 | { | ||
323 | this.listeners[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position); | ||
324 | return true; | ||
325 | } | ||
326 | RegionInfo regInfo = this.RequestNeighbourInfo(regionHandle); | ||
327 | if (regInfo != null) | ||
328 | { | ||
329 | bool retValue = false; | ||
330 | |||
331 | |||
332 | OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( | ||
333 | typeof(OGS1InterRegionRemoting), | ||
334 | "tcp://" + regInfo.RemotingAddress + ":" + regInfo.RemotingPort + "/InterRegions"); | ||
335 | if (remObject != null) | ||
336 | { | ||
337 | |||
338 | retValue = remObject.ExpectAvatarCrossing(regionHandle, agentID, position); | ||
339 | } | ||
340 | else | ||
341 | { | ||
342 | Console.WriteLine("remoting object not found"); | ||
343 | } | ||
344 | remObject = null; | ||
345 | |||
346 | |||
347 | return retValue; | ||
348 | } | ||
349 | //TODO need to see if we know about where this region is and use .net remoting | ||
350 | // to inform it. | ||
351 | return false; | ||
352 | } | ||
353 | #endregion | ||
354 | |||
355 | #region Methods triggered by calls from external instances | ||
356 | public bool IncomingChildAgent(ulong regionHandle, AgentCircuitData agentData) | ||
357 | { | ||
358 | if (this.listeners.ContainsKey(regionHandle)) | ||
359 | { | ||
360 | this.listeners[regionHandle].TriggerExpectUser(regionHandle, agentData); | ||
361 | return true; | ||
362 | } | ||
363 | return false; | ||
364 | } | ||
365 | |||
366 | public bool IncomingArrival(ulong regionHandle, LLUUID agentID, LLVector3 position) | ||
367 | { | ||
368 | if (this.listeners.ContainsKey(regionHandle)) | ||
369 | { | ||
370 | this.listeners[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position); | ||
371 | return true; | ||
372 | } | ||
373 | return false; | ||
374 | } | ||
375 | #endregion | ||
376 | #endregion | ||
377 | } | ||
378 | } | ||
diff --git a/OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs b/OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs new file mode 100644 index 0000000..f514a29 --- /dev/null +++ b/OpenSim/Region/Communications/OGS1/OGS1InterSimComms.cs | |||
@@ -0,0 +1,69 @@ | |||
1 | using System; | ||
2 | using libsecondlife; | ||
3 | using OpenSim.Framework.Types; | ||
4 | |||
5 | namespace OpenSim.Region.Communications.OGS1 | ||
6 | { | ||
7 | public delegate bool InformRegionChild(ulong regionHandle, AgentCircuitData agentData); | ||
8 | public delegate bool ExpectArrival(ulong regionHandle, LLUUID agentID, LLVector3 position); | ||
9 | |||
10 | public sealed class InterRegionSingleton | ||
11 | { | ||
12 | static readonly InterRegionSingleton instance = new InterRegionSingleton(); | ||
13 | |||
14 | public event InformRegionChild OnChildAgent; | ||
15 | public event ExpectArrival OnArrival; | ||
16 | |||
17 | static InterRegionSingleton() | ||
18 | { | ||
19 | } | ||
20 | |||
21 | InterRegionSingleton() | ||
22 | { | ||
23 | } | ||
24 | |||
25 | public static InterRegionSingleton Instance | ||
26 | { | ||
27 | get | ||
28 | { | ||
29 | return instance; | ||
30 | } | ||
31 | } | ||
32 | |||
33 | public bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData) | ||
34 | { | ||
35 | if (OnChildAgent != null) | ||
36 | { | ||
37 | return OnChildAgent(regionHandle, agentData); | ||
38 | } | ||
39 | return false; | ||
40 | } | ||
41 | |||
42 | public bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position) | ||
43 | { | ||
44 | if (OnArrival != null) | ||
45 | { | ||
46 | return OnArrival(regionHandle, agentID, position); | ||
47 | } | ||
48 | return false; | ||
49 | } | ||
50 | } | ||
51 | |||
52 | public class OGS1InterRegionRemoting : MarshalByRefObject | ||
53 | { | ||
54 | |||
55 | public OGS1InterRegionRemoting() | ||
56 | { | ||
57 | } | ||
58 | |||
59 | public bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData) | ||
60 | { | ||
61 | return InterRegionSingleton.Instance.InformRegionOfChildAgent(regionHandle, agentData); | ||
62 | } | ||
63 | |||
64 | public bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position) | ||
65 | { | ||
66 | return InterRegionSingleton.Instance.ExpectAvatarCrossing(regionHandle, agentID, position); | ||
67 | } | ||
68 | } | ||
69 | } | ||
diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs new file mode 100644 index 0000000..2bbaf9d --- /dev/null +++ b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs | |||
@@ -0,0 +1,105 @@ | |||
1 | using System; | ||
2 | using System.Collections; | ||
3 | using libsecondlife; | ||
4 | using Nwc.XmlRpc; | ||
5 | using OpenSim.Framework.Communications; | ||
6 | using OpenSim.Framework.Data; | ||
7 | |||
8 | namespace OpenSim.Region.Communications.OGS1 | ||
9 | { | ||
10 | public class OGS1UserServices :IUserServices | ||
11 | { | ||
12 | CommunicationsOGS1 m_parent; | ||
13 | public OGS1UserServices(CommunicationsOGS1 parent) | ||
14 | { | ||
15 | m_parent = parent; | ||
16 | } | ||
17 | |||
18 | public UserProfileData ConvertXMLRPCDataToUserProfile(Hashtable data) | ||
19 | { | ||
20 | if (data.Contains("error_type")) | ||
21 | { | ||
22 | Console.WriteLine("Error sent by user server when trying to get user profile: (" + data["error_type"] + "): " + data["error_desc"]); | ||
23 | return null; | ||
24 | } | ||
25 | |||
26 | UserProfileData userData = new UserProfileData(); | ||
27 | userData.username = (string)data["firstname"]; | ||
28 | userData.surname = (string)data["lastname"]; | ||
29 | userData.UUID = new LLUUID((string)data["uuid"]); | ||
30 | userData.userInventoryURI = (string)data["server_inventory"]; | ||
31 | userData.userAssetURI = (string)data["server_asset"]; | ||
32 | userData.profileFirstText = (string)data["profile_firstlife_about"]; | ||
33 | userData.profileFirstImage = new LLUUID((string)data["profile_firstlife_image"]); | ||
34 | userData.profileCanDoMask = Convert.ToUInt32((string)data["profile_can_do"]); | ||
35 | userData.profileWantDoMask = Convert.ToUInt32(data["profile_want_do"]); | ||
36 | userData.profileImage = new LLUUID((string)data["profile_image"]); | ||
37 | userData.lastLogin = Convert.ToInt32((string)data["profile_lastlogin"]); | ||
38 | userData.homeRegion = Convert.ToUInt64((string)data["home_region"]); | ||
39 | userData.homeLocation = new LLVector3((float)Convert.ToDecimal((string)data["home_coordinates_x"]), (float)Convert.ToDecimal((string)data["home_coordinates_y"]), (float)Convert.ToDecimal((string)data["home_coordinates_z"])); | ||
40 | userData.homeLookAt = new LLVector3((float)Convert.ToDecimal((string)data["home_look_x"]), (float)Convert.ToDecimal((string)data["home_look_y"]), (float)Convert.ToDecimal((string)data["home_look_z"])); | ||
41 | |||
42 | return userData; | ||
43 | } | ||
44 | public UserProfileData GetUserProfile(string firstName, string lastName) | ||
45 | { | ||
46 | return GetUserProfile(firstName + " " + lastName); | ||
47 | } | ||
48 | public UserProfileData GetUserProfile(string name) | ||
49 | { | ||
50 | //try | ||
51 | //{ | ||
52 | Hashtable param = new Hashtable(); | ||
53 | param["avatar_name"] = name; | ||
54 | IList parameters = new ArrayList(); | ||
55 | parameters.Add(param); | ||
56 | XmlRpcRequest req = new XmlRpcRequest("get_user_by_name", parameters); | ||
57 | XmlRpcResponse resp = req.Send(m_parent.ServersInfo.UserURL, 3000); | ||
58 | Hashtable respData = (Hashtable)resp.Value; | ||
59 | |||
60 | return ConvertXMLRPCDataToUserProfile(respData); | ||
61 | //} | ||
62 | //catch (Exception e) | ||
63 | //{ | ||
64 | // Console.WriteLine("Error when trying to fetch profile data by name from remote user server: " + e.Message); | ||
65 | //} | ||
66 | //return null; | ||
67 | } | ||
68 | public UserProfileData GetUserProfile(LLUUID avatarID) | ||
69 | { | ||
70 | try | ||
71 | { | ||
72 | |||
73 | Hashtable param = new Hashtable(); | ||
74 | param["avatar_uuid"] = avatarID.ToString(); | ||
75 | IList parameters = new ArrayList(); | ||
76 | parameters.Add(param); | ||
77 | XmlRpcRequest req = new XmlRpcRequest("get_user_by_uuid", parameters); | ||
78 | XmlRpcResponse resp = req.Send(m_parent.ServersInfo.UserURL, 3000); | ||
79 | Hashtable respData = (Hashtable)resp.Value; | ||
80 | |||
81 | return ConvertXMLRPCDataToUserProfile(respData); | ||
82 | } | ||
83 | catch (Exception e) | ||
84 | { | ||
85 | Console.WriteLine("Error when trying to fetch profile data by uuid from remote user server: " + e.Message); | ||
86 | } | ||
87 | return null; | ||
88 | } | ||
89 | |||
90 | public UserProfileData SetupMasterUser(string firstName, string lastName) | ||
91 | { | ||
92 | return SetupMasterUser(firstName, lastName, ""); | ||
93 | } | ||
94 | |||
95 | public UserProfileData SetupMasterUser(string firstName, string lastName, string password) | ||
96 | { | ||
97 | UserProfileData profile = GetUserProfile(firstName, lastName); | ||
98 | if (profile == null) | ||
99 | { | ||
100 | Console.WriteLine("Unknown Master User. Grid Mode: No clue what I should do. Probably would choose the grid owner UUID when that is implemented"); | ||
101 | } | ||
102 | return null; | ||
103 | } | ||
104 | } | ||
105 | } | ||
diff --git a/OpenSim/Region/Communications/OGS1/Properties/AssemblyInfo.cs b/OpenSim/Region/Communications/OGS1/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..41f811a --- /dev/null +++ b/OpenSim/Region/Communications/OGS1/Properties/AssemblyInfo.cs | |||
@@ -0,0 +1,33 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.InteropServices; | ||
3 | // General Information about an assembly is controlled through the following | ||
4 | // set of attributes. Change these attribute values to modify the information | ||
5 | // associated with an assembly. | ||
6 | [assembly: AssemblyTitle("OpenGrid.Framework.Communications.OGS1")] | ||
7 | [assembly: AssemblyDescription("")] | ||
8 | [assembly: AssemblyConfiguration("")] | ||
9 | [assembly: AssemblyCompany("")] | ||
10 | [assembly: AssemblyProduct("OpenGrid.Framework.Communications.OGS1")] | ||
11 | [assembly: AssemblyCopyright("Copyright © 2007")] | ||
12 | [assembly: AssemblyTrademark("")] | ||
13 | [assembly: AssemblyCulture("")] | ||
14 | |||
15 | // Setting ComVisible to false makes the types in this assembly not visible | ||
16 | // to COM components. If you need to access a type in this assembly from | ||
17 | // COM, set the ComVisible attribute to true on that type. | ||
18 | [assembly: ComVisible(false)] | ||
19 | |||
20 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
21 | [assembly: Guid("a8b2b39b-c83b-41e2-b0b5-7ccfc1fddae7")] | ||
22 | |||
23 | // Version information for an assembly consists of the following four values: | ||
24 | // | ||
25 | // Major Version | ||
26 | // Minor Version | ||
27 | // Build Number | ||
28 | // Revision | ||
29 | // | ||
30 | // You can specify all the values or you can default the Revision and Build Numbers | ||
31 | // by using the '*' as shown below: | ||
32 | [assembly: AssemblyVersion("1.0.0.0")] | ||
33 | [assembly: AssemblyFileVersion("1.0.0.0")] | ||