aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/UserServer/UserLoginService.cs
diff options
context:
space:
mode:
authorAdam Frisby2008-05-01 18:04:42 +0000
committerAdam Frisby2008-05-01 18:04:42 +0000
commit20a9bf08f51351e1e0a9de94f184ff56cd572665 (patch)
tree52da64dab26353b903c8e4befed0178fa72a188b /OpenSim/Grid/UserServer/UserLoginService.cs
parentMore config cleanup in LaunchSLClient. (diff)
downloadopensim-SC_OLD-20a9bf08f51351e1e0a9de94f184ff56cd572665.zip
opensim-SC_OLD-20a9bf08f51351e1e0a9de94f184ff56cd572665.tar.gz
opensim-SC_OLD-20a9bf08f51351e1e0a9de94f184ff56cd572665.tar.bz2
opensim-SC_OLD-20a9bf08f51351e1e0a9de94f184ff56cd572665.tar.xz
* Rolled back a few changes.
Diffstat (limited to 'OpenSim/Grid/UserServer/UserLoginService.cs')
-rw-r--r--OpenSim/Grid/UserServer/UserLoginService.cs118
1 files changed, 56 insertions, 62 deletions
diff --git a/OpenSim/Grid/UserServer/UserLoginService.cs b/OpenSim/Grid/UserServer/UserLoginService.cs
index b19b74d..b123b8c 100644
--- a/OpenSim/Grid/UserServer/UserLoginService.cs
+++ b/OpenSim/Grid/UserServer/UserLoginService.cs
@@ -41,26 +41,26 @@ using OpenSim.Framework.Servers;
41namespace OpenSim.Grid.UserServer 41namespace OpenSim.Grid.UserServer
42{ 42{
43 public delegate void UserLoggedInAtLocation(LLUUID agentID, LLUUID sessionID, LLUUID RegionID, 43 public delegate void UserLoggedInAtLocation(LLUUID agentID, LLUUID sessionID, LLUUID RegionID,
44 ulong regionhandle, float positionX, float positionY, float positionZ, string firstname, string lastname); 44 ulong regionhandle, float positionX, float positionY, float positionZ, string firstname, string lastname);
45 45
46 public class UserLoginService : LoginService 46 public class UserLoginService : LoginService
47 { 47 {
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49 49
50 private UserLoggedInAtLocation handlerUserLoggedInAtLocation; 50 public event UserLoggedInAtLocation OnUserLoggedInAtLocation;
51 51
52 private UserLoggedInAtLocation handlerUserLoggedInAtLocation = null;
53
52 public UserConfig m_config; 54 public UserConfig m_config;
53 55
54 public UserLoginService( 56 public UserLoginService(
55 UserManagerBase userManager, LibraryRootFolder libraryRootFolder, 57 UserManagerBase userManager, LibraryRootFolder libraryRootFolder,
56 UserConfig config, string welcomeMess) 58 UserConfig config, string welcomeMess)
57 : base(userManager, libraryRootFolder, welcomeMess) 59 : base(userManager, libraryRootFolder, welcomeMess)
58 { 60 {
59 m_config = config; 61 m_config = config;
60 } 62 }
61 63
62 public event UserLoggedInAtLocation OnUserLoggedInAtLocation;
63
64 /// <summary> 64 /// <summary>
65 /// Customises the login response and fills in missing values. 65 /// Customises the login response and fills in missing values.
66 /// </summary> 66 /// </summary>
@@ -95,8 +95,7 @@ namespace OpenSim.Grid.UserServer
95 else 95 else
96 { 96 {
97 string[] startLocationRequestParsed = Util.ParseStartLocationRequest(startLocationRequest); 97 string[] startLocationRequestParsed = Util.ParseStartLocationRequest(startLocationRequest);
98 m_log.Info("[DEBUGLOGINPARSE]: 1:" + startLocationRequestParsed[0] + ", 2:" + startLocationRequestParsed[1] + ", 3:" + 98 m_log.Info("[DEBUGLOGINPARSE]: 1:" + startLocationRequestParsed[0] + ", 2:" + startLocationRequestParsed[1] + ", 3:" + startLocationRequestParsed[2] + ", 4:" + startLocationRequestParsed[3]);
99 startLocationRequestParsed[2] + ", 4:" + startLocationRequestParsed[3]);
100 if (startLocationRequestParsed[0] == "last") 99 if (startLocationRequestParsed[0] == "last")
101 { 100 {
102 // TODO: Parse out startlocationrequest string in the format; 'uri:RegionName&X&Y&Z' 101 // TODO: Parse out startlocationrequest string in the format; 'uri:RegionName&X&Y&Z'
@@ -109,9 +108,9 @@ namespace OpenSim.Grid.UserServer
109 { 108 {
110 m_log.Info("[LOGIN]: Looking up Sim: " + startLocationRequestParsed[0]); 109 m_log.Info("[LOGIN]: Looking up Sim: " + startLocationRequestParsed[0]);
111 SimInfo = 110 SimInfo =
112 RegionProfileData.RequestSimProfileData( 111 RegionProfileData.RequestSimProfileData(
113 startLocationRequestParsed[0], m_config.GridServerURL, 112 startLocationRequestParsed[0], m_config.GridServerURL,
114 m_config.GridSendKey, m_config.GridRecvKey); 113 m_config.GridSendKey, m_config.GridRecvKey);
115 114
116 if (SimInfo == null) 115 if (SimInfo == null)
117 { 116 {
@@ -120,9 +119,7 @@ namespace OpenSim.Grid.UserServer
120 RegionProfileData.RequestSimProfileData( 119 RegionProfileData.RequestSimProfileData(
121 theUser.HomeRegion, m_config.GridServerURL, 120 theUser.HomeRegion, m_config.GridServerURL,
122 m_config.GridSendKey, m_config.GridRecvKey); 121 m_config.GridSendKey, m_config.GridRecvKey);
123 } 122 } else {
124 else
125 {
126 start_x = Convert.ToInt32(startLocationRequestParsed[1]); 123 start_x = Convert.ToInt32(startLocationRequestParsed[1]);
127 start_y = Convert.ToInt32(startLocationRequestParsed[2]); 124 start_y = Convert.ToInt32(startLocationRequestParsed[2]);
128 start_z = Convert.ToInt32(startLocationRequestParsed[3]); 125 start_z = Convert.ToInt32(startLocationRequestParsed[3]);
@@ -133,30 +130,30 @@ namespace OpenSim.Grid.UserServer
133 // Customise the response 130 // Customise the response
134 //CFK: This is redundant and the next message should always appear. 131 //CFK: This is redundant and the next message should always appear.
135 //CFK: m_log.Info("[LOGIN]: Home Location"); 132 //CFK: m_log.Info("[LOGIN]: Home Location");
136 response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * Constants.RegionSize) + ",r" + 133 response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * Constants.RegionSize).ToString() + ",r" +
137 (SimInfo.regionLocY * Constants.RegionSize) + "], " + 134 (SimInfo.regionLocY * Constants.RegionSize).ToString() + "], " +
138 "'position':[r" + theUser.HomeLocation.X + ",r" + 135 "'position':[r" + theUser.HomeLocation.X.ToString() + ",r" +
139 theUser.HomeLocation.Y + ",r" + theUser.HomeLocation.Z + "], " + 136 theUser.HomeLocation.Y.ToString() + ",r" + theUser.HomeLocation.Z.ToString() + "], " +
140 "'look_at':[r" + theUser.HomeLocation.X + ",r" + 137 "'look_at':[r" + theUser.HomeLocation.X.ToString() + ",r" +
141 theUser.HomeLocation.Y + ",r" + theUser.HomeLocation.Z + "]}"; 138 theUser.HomeLocation.Y.ToString() + ",r" + theUser.HomeLocation.Z.ToString() + "]}";
142 139
143 // Destination 140 // Destination
144 //CFK: The "Notifying" message always seems to appear, so subsume the data from this message into 141 //CFK: The "Notifying" message always seems to appear, so subsume the data from this message into
145 //CFK: the next one for X & Y and comment this one. 142 //CFK: the next one for X & Y and comment this one.
146 //CFK: m_log.Info("[LOGIN]: CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + 143 //CFK: m_log.Info("[LOGIN]: CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX +
147 //CFK: "; Region Y: " + SimInfo.regionLocY); 144 //CFK: "; Region Y: " + SimInfo.regionLocY);
148 response.SimAddress = Util.GetHostFromDNS(SimInfo.serverURI.Split(new[] {'/', ':'})[3]).ToString(); 145 response.SimAddress = Util.GetHostFromDNS(SimInfo.serverURI.Split(new char[] { '/', ':' })[3]).ToString();
149 response.SimPort = uint.Parse(SimInfo.serverURI.Split(new[] {'/', ':'})[4]); 146 response.SimPort = uint.Parse(SimInfo.serverURI.Split(new char[] { '/', ':' })[4]);
150 response.RegionX = SimInfo.regionLocX; 147 response.RegionX = SimInfo.regionLocX;
151 response.RegionY = SimInfo.regionLocY; 148 response.RegionY = SimInfo.regionLocY;
152 149
153 //Not sure if the + "/CAPS/" should in fact be +"CAPS/" depending if there is already a / as part of httpServerURI 150 //Not sure if the + "/CAPS/" should in fact be +"CAPS/" depending if there is already a / as part of httpServerURI
154 string capsPath = Util.GetRandomCapsPath(); 151 string capsPath = Util.GetRandomCapsPath();
155 response.SeedCapability = SimInfo.httpServerURI + "CAPS/" + capsPath + "0000/"; 152 response.SeedCapability = SimInfo.httpServerURI + "CAPS/" + capsPath + "0000/";
156 153
157 m_log.DebugFormat( 154 m_log.DebugFormat(
158 "[LOGIN]: Sending new CAPS seed url {0} to client {1}", 155 "[LOGIN]: Sending new CAPS seed url {0} to client {1}",
159 response.SeedCapability, response.AgentID); 156 response.SeedCapability, response.AgentID);
160 157
161 // Notify the target of an incoming user 158 // Notify the target of an incoming user
162 //CFK: The "Notifying" message always seems to appear, so subsume the data from this message into 159 //CFK: The "Notifying" message always seems to appear, so subsume the data from this message into
@@ -166,8 +163,7 @@ namespace OpenSim.Grid.UserServer
166 163
167 theUser.CurrentAgent.Region = SimInfo.UUID; 164 theUser.CurrentAgent.Region = SimInfo.UUID;
168 theUser.CurrentAgent.Handle = SimInfo.regionHandle; 165 theUser.CurrentAgent.Handle = SimInfo.regionHandle;
169 if (start_x >= 0 && start_y >= 0 && start_z >= 0) 166 if (start_x >= 0 && start_y >= 0 && start_z >= 0) {
170 {
171 LLVector3 tmp_v = new LLVector3(start_x, start_y, start_z); 167 LLVector3 tmp_v = new LLVector3(start_x, start_y, start_z);
172 theUser.CurrentAgent.Position = tmp_v; 168 theUser.CurrentAgent.Position = tmp_v;
173 } 169 }
@@ -190,43 +186,42 @@ namespace OpenSim.Grid.UserServer
190 // Update agent with target sim 186 // Update agent with target sim
191 187
192 m_log.InfoFormat( 188 m_log.InfoFormat(
193 "[LOGIN]: Telling region {0} @ {1},{2} ({3}) to expect user connection", 189 "[LOGIN]: Telling region {0} @ {1},{2} ({3}) to expect user connection",
194 SimInfo.regionName, response.RegionX, response.RegionY, SimInfo.httpServerURI); 190 SimInfo.regionName, response.RegionX, response.RegionY, SimInfo.httpServerURI);
195 191
196 XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams); 192 XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams);
197 XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000); 193 XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000);
198 194
199 if (GridResp.IsFault) 195 if (GridResp.IsFault)
200 { 196 {
201 m_log.ErrorFormat( 197 m_log.ErrorFormat(
202 "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}", 198 "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}",
203 SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString); 199 SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString);
204 } 200 }
205 handlerUserLoggedInAtLocation = OnUserLoggedInAtLocation; 201 handlerUserLoggedInAtLocation = OnUserLoggedInAtLocation;
206 if (handlerUserLoggedInAtLocation != null) 202 if (handlerUserLoggedInAtLocation != null)
207 { 203 {
208 //m_log.Info("[LOGIN]: Letting other objects know about login"); 204 //m_log.Info("[LOGIN]: Letting other objects know about login");
209 handlerUserLoggedInAtLocation(theUser.ID, theUser.CurrentAgent.SessionID, theUser.CurrentAgent.Region, 205 handlerUserLoggedInAtLocation(theUser.ID, theUser.CurrentAgent.SessionID, theUser.CurrentAgent.Region,
210 theUser.CurrentAgent.Handle, theUser.CurrentAgent.Position.X, theUser.CurrentAgent.Position.Y, 206 theUser.CurrentAgent.Handle, theUser.CurrentAgent.Position.X,theUser.CurrentAgent.Position.Y,theUser.CurrentAgent.Position.Z,
211 theUser.CurrentAgent.Position.Z, 207 theUser.FirstName,theUser.SurName);
212 theUser.FirstName, theUser.SurName);
213 } 208 }
214 } 209 }
215 catch (Exception) 210 catch (Exception)
216 //catch (System.AccessViolationException) 211 //catch (System.AccessViolationException)
217 { 212 {
218 tryDefault = true; 213 tryDefault = true;
219 } 214 }
220 215
221 if (tryDefault) 216 if (tryDefault)
222 { 217 {
223 // Send him to default region instead 218 // Send him to default region instead
224 // Load information from the gridserver 219 // Load information from the gridserver
225 220
226 ulong defaultHandle = (((ulong) m_config.DefaultX * Constants.RegionSize) << 32) | ((ulong) m_config.DefaultY * Constants.RegionSize); 221 ulong defaultHandle = (((ulong)m_config.DefaultX * Constants.RegionSize) << 32) | ((ulong)m_config.DefaultY * Constants.RegionSize);
227 222
228 m_log.Warn( 223 m_log.Warn(
229 "[LOGIN]: Home region not available: sending to default " + defaultHandle); 224 "[LOGIN]: Home region not available: sending to default " + defaultHandle.ToString());
230 225
231 try 226 try
232 { 227 {
@@ -236,19 +231,19 @@ namespace OpenSim.Grid.UserServer
236 231
237 // Customise the response 232 // Customise the response
238 m_log.Info("[LOGIN]: Home Location"); 233 m_log.Info("[LOGIN]: Home Location");
239 response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * Constants.RegionSize) + ",r" + 234 response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * Constants.RegionSize).ToString() + ",r" +
240 (SimInfo.regionLocY * Constants.RegionSize) + "], " + 235 (SimInfo.regionLocY * Constants.RegionSize).ToString() + "], " +
241 "'position':[r" + theUser.HomeLocation.X + ",r" + 236 "'position':[r" + theUser.HomeLocation.X.ToString() + ",r" +
242 theUser.HomeLocation.Y + ",r" + theUser.HomeLocation.Z + "], " + 237 theUser.HomeLocation.Y.ToString() + ",r" + theUser.HomeLocation.Z.ToString() + "], " +
243 "'look_at':[r" + theUser.HomeLocation.X + ",r" + 238 "'look_at':[r" + theUser.HomeLocation.X.ToString() + ",r" +
244 theUser.HomeLocation.Y + ",r" + theUser.HomeLocation.Z + "]}"; 239 theUser.HomeLocation.Y.ToString() + ",r" + theUser.HomeLocation.Z.ToString() + "]}";
245 240
246 // Destination 241 // Destination
247 m_log.Info("[LOGIN]: " + 242 m_log.Info("[LOGIN]: " +
248 "CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " + 243 "CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " +
249 SimInfo.regionLocY); 244 SimInfo.regionLocY);
250 response.SimAddress = Util.GetHostFromDNS(SimInfo.serverURI.Split(new[] {'/', ':'})[3]).ToString(); 245 response.SimAddress = Util.GetHostFromDNS(SimInfo.serverURI.Split(new char[] { '/', ':' })[3]).ToString();
251 response.SimPort = uint.Parse(SimInfo.serverURI.Split(new[] {'/', ':'})[4]); 246 response.SimPort = uint.Parse(SimInfo.serverURI.Split(new char[] { '/', ':' })[4]);
252 response.RegionX = SimInfo.regionLocX; 247 response.RegionX = SimInfo.regionLocX;
253 response.RegionY = SimInfo.regionLocY; 248 response.RegionY = SimInfo.regionLocY;
254 249
@@ -288,16 +283,15 @@ namespace OpenSim.Grid.UserServer
288 { 283 {
289 m_log.Info("[LOGIN]: Letting other objects know about login"); 284 m_log.Info("[LOGIN]: Letting other objects know about login");
290 handlerUserLoggedInAtLocation(theUser.ID, theUser.CurrentAgent.SessionID, theUser.CurrentAgent.Region, 285 handlerUserLoggedInAtLocation(theUser.ID, theUser.CurrentAgent.SessionID, theUser.CurrentAgent.Region,
291 theUser.CurrentAgent.Handle, theUser.CurrentAgent.Position.X, theUser.CurrentAgent.Position.Y, 286 theUser.CurrentAgent.Handle, theUser.CurrentAgent.Position.X, theUser.CurrentAgent.Position.Y, theUser.CurrentAgent.Position.Z,
292 theUser.CurrentAgent.Position.Z, 287 theUser.FirstName, theUser.SurName);
293 theUser.FirstName, theUser.SurName);
294 } 288 }
295 } 289 }
296 290
297 catch (Exception e) 291 catch (Exception e)
298 { 292 {
299 m_log.Warn("[LOGIN]: Default region also not available"); 293 m_log.Warn("[LOGIN]: Default region also not available");
300 m_log.Warn("[LOGIN]: " + e); 294 m_log.Warn("[LOGIN]: " + e.ToString());
301 } 295 }
302 } 296 }
303 } 297 }
@@ -306,8 +300,8 @@ namespace OpenSim.Grid.UserServer
306 protected override InventoryData GetInventorySkeleton(LLUUID userID) 300 protected override InventoryData GetInventorySkeleton(LLUUID userID)
307 { 301 {
308 m_log.DebugFormat( 302 m_log.DebugFormat(
309 "[LOGIN]: Contacting inventory service at {0} for inventory skeleton of user {1}", 303 "[LOGIN]: Contacting inventory service at {0} for inventory skeleton of user {1}",
310 m_config.InventoryUrl, userID); 304 m_config.InventoryUrl, userID);
311 305
312 List<InventoryFolderBase> folders 306 List<InventoryFolderBase> folders
313 = SynchronousRestObjectPoster.BeginPostObject<Guid, List<InventoryFolderBase>>( 307 = SynchronousRestObjectPoster.BeginPostObject<Guid, List<InventoryFolderBase>>(
@@ -322,23 +316,23 @@ namespace OpenSim.Grid.UserServer
322 // tools are creating the user profile directly in the database without creating the inventory. At 316 // tools are creating the user profile directly in the database without creating the inventory. At
323 // this time we'll accomodate them by lazily creating the user inventory now if it doesn't already 317 // this time we'll accomodate them by lazily creating the user inventory now if it doesn't already
324 // exist. 318 // exist.
325 bool created = 319 bool created =
326 SynchronousRestObjectPoster.BeginPostObject<Guid, bool>( 320 SynchronousRestObjectPoster.BeginPostObject<Guid, bool>(
327 "POST", m_config.InventoryUrl + "CreateInventory/", userID.UUID); 321 "POST", m_config.InventoryUrl + "CreateInventory/", userID.UUID);
328 322
329 if (!created) 323 if (!created)
330 { 324 {
331 throw new Exception( 325 throw new Exception(
332 String.Format( 326 String.Format(
333 "The inventory creation request for user {0} did not succeed." 327 "The inventory creation request for user {0} did not succeed."
334 + " Please contact your inventory service provider for more information.", 328 + " Please contact your inventory service provider for more information.",
335 userID)); 329 userID));
336 } 330 }
337 else 331 else
338 { 332 {
339 m_log.InfoFormat("[LOGIN]: A new inventory skeleton was successfully created for user {0}", userID); 333 m_log.InfoFormat("[LOGIN]: A new inventory skeleton was successfully created for user {0}", userID);
340 } 334 }
341 335
342 folders = SynchronousRestObjectPoster.BeginPostObject<Guid, List<InventoryFolderBase>>( 336 folders = SynchronousRestObjectPoster.BeginPostObject<Guid, List<InventoryFolderBase>>(
343 "POST", m_config.InventoryUrl + "RootFolders/", userID.UUID); 337 "POST", m_config.InventoryUrl + "RootFolders/", userID.UUID);
344 } 338 }
@@ -348,11 +342,11 @@ namespace OpenSim.Grid.UserServer
348 LLUUID rootID = LLUUID.Zero; 342 LLUUID rootID = LLUUID.Zero;
349 ArrayList AgentInventoryArray = new ArrayList(); 343 ArrayList AgentInventoryArray = new ArrayList();
350 Hashtable TempHash; 344 Hashtable TempHash;
351 345
352 foreach (InventoryFolderBase InvFolder in folders) 346 foreach (InventoryFolderBase InvFolder in folders)
353 { 347 {
354// m_log.DebugFormat("[LOGIN]: Received agent inventory folder {0}", InvFolder.name); 348// m_log.DebugFormat("[LOGIN]: Received agent inventory folder {0}", InvFolder.name);
355 349
356 if (InvFolder.ParentID == LLUUID.Zero) 350 if (InvFolder.ParentID == LLUUID.Zero)
357 { 351 {
358 rootID = InvFolder.ID; 352 rootID = InvFolder.ID;
@@ -365,16 +359,16 @@ namespace OpenSim.Grid.UserServer
365 TempHash["folder_id"] = InvFolder.ID.ToString(); 359 TempHash["folder_id"] = InvFolder.ID.ToString();
366 AgentInventoryArray.Add(TempHash); 360 AgentInventoryArray.Add(TempHash);
367 } 361 }
368 362
369 return new InventoryData(AgentInventoryArray, rootID); 363 return new InventoryData(AgentInventoryArray, rootID);
370 } 364 }
371 else 365 else
372 { 366 {
373 throw new Exception( 367 throw new Exception(
374 String.Format( 368 String.Format(
375 "A root inventory folder for user {0} could not be retrieved from the inventory service", 369 "A root inventory folder for user {0} could not be retrieved from the inventory service",
376 userID)); 370 userID));
377 } 371 }
378 } 372 }
379 } 373 }
380} \ No newline at end of file 374}