aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Communications')
-rw-r--r--OpenSim/Framework/Communications/CommunicationsManager.cs14
-rw-r--r--OpenSim/Framework/Communications/IUserService.cs13
-rw-r--r--OpenSim/Framework/Communications/LoginService.cs35
-rw-r--r--OpenSim/Framework/Communications/UserManagerBase.cs196
4 files changed, 130 insertions, 128 deletions
diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs
index e6413e8..969bdd8 100644
--- a/OpenSim/Framework/Communications/CommunicationsManager.cs
+++ b/OpenSim/Framework/Communications/CommunicationsManager.cs
@@ -276,13 +276,25 @@ namespace OpenSim.Framework.Communications
276 /// <param name="userid"></param> 276 /// <param name="userid"></param>
277 /// <param name="regionid"></param> 277 /// <param name="regionid"></param>
278 /// <param name="regionhandle"></param> 278 /// <param name="regionhandle"></param>
279 /// <param name="position"></param>
280 /// <param name="lookat"></param>
281 public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat)
282 {
283 m_userService.LogOffUser(userid, regionid, regionhandle, position, lookat);
284 }
285
286 /// <summary>
287 /// Logs off a user and does the appropriate communications (deprecated as of 2008-08-27)
288 /// </summary>
289 /// <param name="userid"></param>
290 /// <param name="regionid"></param>
291 /// <param name="regionhandle"></param>
279 /// <param name="posx"></param> 292 /// <param name="posx"></param>
280 /// <param name="posy"></param> 293 /// <param name="posy"></param>
281 /// <param name="posz"></param> 294 /// <param name="posz"></param>
282 public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz) 295 public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz)
283 { 296 {
284 m_userService.LogOffUser(userid, regionid, regionhandle, posx, posy, posz); 297 m_userService.LogOffUser(userid, regionid, regionhandle, posx, posy, posz);
285
286 } 298 }
287 299
288 /// <summary> 300 /// <summary>
diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs
index 07ea437..7e3c77b 100644
--- a/OpenSim/Framework/Communications/IUserService.cs
+++ b/OpenSim/Framework/Communications/IUserService.cs
@@ -106,7 +106,18 @@ namespace OpenSim.Framework.Communications
106 /// Logs off a user on the user server 106 /// Logs off a user on the user server
107 /// </summary> 107 /// </summary>
108 /// <param name="UserID">UUID of the user</param> 108 /// <param name="UserID">UUID of the user</param>
109 /// <param name="regionData">UUID of the Region</param> 109 /// <param name="regionID">UUID of the Region</param>
110 /// <param name="regionhandle">regionhandle</param>
111 /// <param name="position">final position</param>
112 /// <param name="lookat">final lookat</param>
113 void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat);
114
115 /// <summary>
116 /// Logs off a user on the user server (deprecated as of 2008-08-27)
117 /// </summary>
118 /// <param name="UserID">UUID of the user</param>
119 /// <param name="regionID">UUID of the Region</param>
120 /// <param name="regionhandle">regionhandle</param>
110 /// <param name="posx">final position x</param> 121 /// <param name="posx">final position x</param>
111 /// <param name="posy">final position y</param> 122 /// <param name="posy">final position y</param>
112 /// <param name="posz">final position z</param> 123 /// <param name="posz">final position z</param>
diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs
index 7cdbf6c..26ae3c6 100644
--- a/OpenSim/Framework/Communications/LoginService.cs
+++ b/OpenSim/Framework/Communications/LoginService.cs
@@ -258,30 +258,19 @@ namespace OpenSim.Framework.Communications
258 InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; 258 InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000";
259 ArrayList InventoryLibRoot = new ArrayList(); 259 ArrayList InventoryLibRoot = new ArrayList();
260 InventoryLibRoot.Add(InventoryLibRootHash); 260 InventoryLibRoot.Add(InventoryLibRootHash);
261 logResponse.InventoryLibRoot = InventoryLibRoot;
262 261
262 logResponse.InventoryLibRoot = InventoryLibRoot;
263 logResponse.InventoryLibraryOwner = GetLibraryOwner(); 263 logResponse.InventoryLibraryOwner = GetLibraryOwner();
264
265 logResponse.InventoryRoot = InventoryRoot; 264 logResponse.InventoryRoot = InventoryRoot;
266 logResponse.InventorySkeleton = AgentInventoryArray; 265 logResponse.InventorySkeleton = AgentInventoryArray;
267 logResponse.InventoryLibrary = GetInventoryLibrary(); 266 logResponse.InventoryLibrary = GetInventoryLibrary();
268 267
269 // Circuit Code 268 logResponse.CircuitCode = (Int32)Util.RandomClass.Next();
270 uint circode = (uint) (Util.RandomClass.Next());
271
272 logResponse.Lastname = userProfile.SurName; 269 logResponse.Lastname = userProfile.SurName;
273 logResponse.Firstname = userProfile.FirstName; 270 logResponse.Firstname = userProfile.FirstName;
274 logResponse.AgentID = agentID.ToString(); 271 logResponse.AgentID = agentID.ToString();
275 logResponse.SessionID = userProfile.CurrentAgent.SessionID.ToString(); 272 logResponse.SessionID = userProfile.CurrentAgent.SessionID.ToString();
276 logResponse.SecureSessionID = userProfile.CurrentAgent.SecureSessionID.ToString(); 273 logResponse.SecureSessionID = userProfile.CurrentAgent.SecureSessionID.ToString();
277
278 logResponse.CircuitCode = (Int32) circode;
279 //logResponse.RegionX = 0; //overwritten
280 //logResponse.RegionY = 0; //overwritten
281 logResponse.Home = "!!null temporary value {home}!!"; // Overwritten
282 //logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n";
283 //logResponse.SimAddress = "127.0.0.1"; //overwritten
284 //logResponse.SimPort = 0; //overwritten
285 logResponse.Message = GetMessage(); 274 logResponse.Message = GetMessage();
286 logResponse.BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID)); 275 logResponse.BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID));
287 logResponse.StartLocation = startLocationRequest; 276 logResponse.StartLocation = startLocationRequest;
@@ -322,6 +311,11 @@ namespace OpenSim.Framework.Communications
322 } 311 }
323 } 312 }
324 313
314 /// <summary>
315 /// Called when we receive the client's initial LLSD login_to_simulator request message
316 /// </summary>
317 /// <param name="request">The LLSD request</param>
318 /// <returns>The response to send</returns>
325 public LLSD LLSDLoginMethod(LLSD request) 319 public LLSD LLSDLoginMethod(LLSD request)
326 { 320 {
327 // Temporary fix 321 // Temporary fix
@@ -432,30 +426,19 @@ namespace OpenSim.Framework.Communications
432 InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; 426 InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000";
433 ArrayList InventoryLibRoot = new ArrayList(); 427 ArrayList InventoryLibRoot = new ArrayList();
434 InventoryLibRoot.Add(InventoryLibRootHash); 428 InventoryLibRoot.Add(InventoryLibRootHash);
435 logResponse.InventoryLibRoot = InventoryLibRoot;
436 429
430 logResponse.InventoryLibRoot = InventoryLibRoot;
437 logResponse.InventoryLibraryOwner = GetLibraryOwner(); 431 logResponse.InventoryLibraryOwner = GetLibraryOwner();
438
439 logResponse.InventoryRoot = InventoryRoot; 432 logResponse.InventoryRoot = InventoryRoot;
440 logResponse.InventorySkeleton = AgentInventoryArray; 433 logResponse.InventorySkeleton = AgentInventoryArray;
441 logResponse.InventoryLibrary = GetInventoryLibrary(); 434 logResponse.InventoryLibrary = GetInventoryLibrary();
442 435
443 // Circuit Code 436 logResponse.CircuitCode = (Int32)Util.RandomClass.Next();
444 uint circode = (uint)(Util.RandomClass.Next());
445
446 logResponse.Lastname = userProfile.SurName; 437 logResponse.Lastname = userProfile.SurName;
447 logResponse.Firstname = userProfile.FirstName; 438 logResponse.Firstname = userProfile.FirstName;
448 logResponse.AgentID = agentID.ToString(); 439 logResponse.AgentID = agentID.ToString();
449 logResponse.SessionID = userProfile.CurrentAgent.SessionID.ToString(); 440 logResponse.SessionID = userProfile.CurrentAgent.SessionID.ToString();
450 logResponse.SecureSessionID = userProfile.CurrentAgent.SecureSessionID.ToString(); 441 logResponse.SecureSessionID = userProfile.CurrentAgent.SecureSessionID.ToString();
451
452 logResponse.CircuitCode = (Int32)circode;
453 //logResponse.RegionX = 0; //overwritten
454 //logResponse.RegionY = 0; //overwritten
455 logResponse.Home = "!!null temporary value {home}!!"; // Overwritten
456 //logResponse.LookAt = "\n[r" + TheUser.homeLookAt.X.ToString() + ",r" + TheUser.homeLookAt.Y.ToString() + ",r" + TheUser.homeLookAt.Z.ToString() + "]\n";
457 //logResponse.SimAddress = "127.0.0.1"; //overwritten
458 //logResponse.SimPort = 0; //overwritten
459 logResponse.Message = GetMessage(); 442 logResponse.Message = GetMessage();
460 logResponse.BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID)); 443 logResponse.BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID));
461 logResponse.StartLocation = startLocationRequest; 444 logResponse.StartLocation = startLocationRequest;
diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs
index b6564bf..75c4dc1 100644
--- a/OpenSim/Framework/Communications/UserManagerBase.cs
+++ b/OpenSim/Framework/Communications/UserManagerBase.cs
@@ -388,84 +388,115 @@ namespace OpenSim.Framework.Communications
388 // Profile UUID 388 // Profile UUID
389 agent.ProfileID = profile.ID; 389 agent.ProfileID = profile.ID;
390 390
391 // Current position (from Home) 391 // Current location/position/alignment
392 agent.Handle = profile.HomeRegion; 392 if (profile.CurrentAgent != null)
393 agent.Position = profile.HomeLocation;
394
395 // If user specified additional start, use that
396 if (requestData.ContainsKey("start"))
397 { 393 {
398 string startLoc = ((string)requestData["start"]).Trim(); 394 agent.Region = profile.CurrentAgent.Region;
399 if (("last" == startLoc) && (profile.CurrentAgent != null)) 395 agent.Handle = profile.CurrentAgent.Handle;
400 { 396 agent.Position = profile.CurrentAgent.Position;
401 if ((profile.CurrentAgent.Position.X > 0) 397 agent.LookAt = profile.CurrentAgent.LookAt;
402 && (profile.CurrentAgent.Position.Y > 0) 398 }
403 && (profile.CurrentAgent.Position.Z > 0) 399 else
404 ) 400 {
405 { 401 agent.Region = profile.HomeRegionID;
406 // TODO: Right now, currentRegion has not been used in GridServer for requesting region. 402 agent.Handle = profile.HomeRegion;
407 // TODO: It is only using currentHandle. 403 agent.Position = profile.HomeLocation;
408 agent.Region = profile.CurrentAgent.Region; 404 agent.LookAt = profile.HomeLookAt;
409 agent.Handle = profile.CurrentAgent.Handle;
410 agent.Position = profile.CurrentAgent.Position;
411 }
412 }
413
414// if (!(startLoc == "last" || startLoc == "home"))
415// {
416// // Format: uri:Ahern&162&213&34
417// try
418// {
419// string[] parts = startLoc.Remove(0, 4).Split('&');
420// //string region = parts[0];
421//
422// ////////////////////////////////////////////////////
423// //SimProfile SimInfo = new SimProfile();
424// //SimInfo = SimInfo.LoadFromGrid(theUser.currentAgent.currentHandle, _config.GridServerURL, _config.GridSendKey, _config.GridRecvKey);
425// }
426// catch (Exception)
427// {
428// }
429// }
430 } 405 }
431 406
432 // What time did the user login? 407 // What time did the user login?
433 agent.LoginTime = Util.UnixTimeSinceEpoch(); 408 agent.LoginTime = Util.UnixTimeSinceEpoch();
434 agent.LogoutTime = 0; 409 agent.LogoutTime = 0;
435 410
436 // Current location 411 profile.CurrentAgent = agent;
437 agent.InitialRegion = UUID.Zero; // Fill in later 412 }
438 agent.Region = UUID.Zero; // Fill in later 413
414 public void CreateAgent(UserProfileData profile, LLSD request)
415 {
416 UserAgentData agent = new UserAgentData();
417
418 // User connection
419 agent.AgentOnline = true;
420
421 //if (request.Params.Count > 1)
422 //{
423 // IPEndPoint RemoteIPEndPoint = (IPEndPoint)request.Params[1];
424 // agent.AgentIP = RemoteIPEndPoint.Address.ToString();
425 // agent.AgentPort = (uint)RemoteIPEndPoint.Port;
426 //}
427
428 // Generate sessions
429 RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider();
430 byte[] randDataS = new byte[16];
431 byte[] randDataSS = new byte[16];
432 rand.GetBytes(randDataS);
433 rand.GetBytes(randDataSS);
434
435 agent.SecureSessionID = new UUID(randDataSS, 0);
436 agent.SessionID = new UUID(randDataS, 0);
437
438 // Profile UUID
439 agent.ProfileID = profile.ID;
440
441 // Current location/position/alignment
442 if (profile.CurrentAgent != null)
443 {
444 agent.Region = profile.CurrentAgent.Region;
445 agent.Handle = profile.CurrentAgent.Handle;
446 agent.Position = profile.CurrentAgent.Position;
447 agent.LookAt = profile.CurrentAgent.LookAt;
448 }
449 else
450 {
451 agent.Region = profile.HomeRegionID;
452 agent.Handle = profile.HomeRegion;
453 agent.Position = profile.HomeLocation;
454 agent.LookAt = profile.HomeLookAt;
455 }
456
457 // What time did the user login?
458 agent.LoginTime = Util.UnixTimeSinceEpoch();
459 agent.LogoutTime = 0;
439 460
440 profile.CurrentAgent = agent; 461 profile.CurrentAgent = agent;
441 } 462 }
442 463
443 /// <summary> 464 /// <summary>
465 /// Saves a target agent to the database
466 /// </summary>
467 /// <param name="profile">The users profile</param>
468 /// <returns>Successful?</returns>
469 public bool CommitAgent(ref UserProfileData profile)
470 {
471 // TODO: how is this function different from setUserProfile? -> Add AddUserAgent() here and commit both tables "users" and "agents"
472 // TODO: what is the logic should be?
473 bool ret = false;
474 ret = AddUserAgent(profile.CurrentAgent);
475 ret = ret & UpdateUserProfile(profile);
476 return ret;
477 }
478
479 /// <summary>
444 /// Process a user logoff from OpenSim. 480 /// Process a user logoff from OpenSim.
445 /// </summary> 481 /// </summary>
446 /// <param name="userid"></param> 482 /// <param name="userid"></param>
447 /// <param name="regionid"></param> 483 /// <param name="regionid"></param>
448 /// <param name="regionhandle"></param> 484 /// <param name="regionhandle"></param>
449 /// <param name="posx"></param> 485 /// <param name="position"></param>
450 /// <param name="posy"></param> 486 /// <param name="lookat"></param>
451 /// <param name="posz"></param> 487 public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat)
452 public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz)
453 { 488 {
454 if (StatsManager.UserStats != null) 489 if (StatsManager.UserStats != null)
455 StatsManager.UserStats.AddLogout(); 490 StatsManager.UserStats.AddLogout();
456 491
457 UserProfileData userProfile; 492 UserProfileData userProfile = GetUserProfile(userid);
458 UserAgentData userAgent;
459 Vector3 currentPos = new Vector3(posx, posy, posz);
460
461 userProfile = GetUserProfile(userid);
462 493
463 if (userProfile != null) 494 if (userProfile != null)
464 { 495 {
465 // This line needs to be in side the above if statement or the UserServer will crash on some logouts. 496 // This line needs to be in side the above if statement or the UserServer will crash on some logouts.
466 m_log.Info("[LOGOUT]: " + userProfile.FirstName + " " + userProfile.SurName + " from " + regionhandle + "(" + posx + "," + posy + "," + posz + ")"); 497 m_log.Info("[LOGOUT]: " + userProfile.FirstName + " " + userProfile.SurName + " from " + regionhandle + "(" + position.X + "," + position.Y + "," + position.Z + ")");
467 498
468 userAgent = userProfile.CurrentAgent; 499 UserAgentData userAgent = userProfile.CurrentAgent;
469 if (userAgent != null) 500 if (userAgent != null)
470 { 501 {
471 userAgent.AgentOnline = false; 502 userAgent.AgentOnline = false;
@@ -475,10 +506,11 @@ namespace OpenSim.Framework.Communications
475 { 506 {
476 userAgent.Region = regionid; 507 userAgent.Region = regionid;
477 } 508 }
478
479 userAgent.Handle = regionhandle; 509 userAgent.Handle = regionhandle;
480 userAgent.Position = currentPos; 510 userAgent.Position = position;
481 userProfile.CurrentAgent = userAgent; 511 userAgent.LookAt = lookat;
512 //userProfile.CurrentAgent = userAgent;
513 userProfile.LastLogin = userAgent.LogoutTime;
482 514
483 CommitAgent(ref userProfile); 515 CommitAgent(ref userProfile);
484 } 516 }
@@ -494,54 +526,18 @@ namespace OpenSim.Framework.Communications
494 } 526 }
495 } 527 }
496 528
497 public void CreateAgent(UserProfileData profile, LLSD request)
498 {
499 UserAgentData agent = new UserAgentData();
500
501 // User connection
502 agent.AgentOnline = true;
503
504 // Generate sessions
505 RNGCryptoServiceProvider rand = new RNGCryptoServiceProvider();
506 byte[] randDataS = new byte[16];
507 byte[] randDataSS = new byte[16];
508 rand.GetBytes(randDataS);
509 rand.GetBytes(randDataSS);
510
511 agent.SecureSessionID = new UUID(randDataSS, 0);
512 agent.SessionID = new UUID(randDataS, 0);
513
514 // Profile UUID
515 agent.ProfileID = profile.ID;
516
517 // Current position (from Home)
518 agent.Handle = profile.HomeRegion;
519 agent.Position = profile.HomeLocation;
520
521 // What time did the user login?
522 agent.LoginTime = Util.UnixTimeSinceEpoch();
523 agent.LogoutTime = 0;
524
525 // Current location
526 agent.InitialRegion = UUID.Zero; // Fill in later
527 agent.Region = UUID.Zero; // Fill in later
528
529 profile.CurrentAgent = agent;
530 }
531
532 /// <summary> 529 /// <summary>
533 /// Saves a target agent to the database 530 /// Process a user logoff from OpenSim (deprecated as of 2008-08-27)
534 /// </summary> 531 /// </summary>
535 /// <param name="profile">The users profile</param> 532 /// <param name="userid"></param>
536 /// <returns>Successful?</returns> 533 /// <param name="regionid"></param>
537 public bool CommitAgent(ref UserProfileData profile) 534 /// <param name="regionhandle"></param>
535 /// <param name="posx"></param>
536 /// <param name="posy"></param>
537 /// <param name="posz"></param>
538 public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz)
538 { 539 {
539 // TODO: how is this function different from setUserProfile? -> Add AddUserAgent() here and commit both tables "users" and "agents" 540 LogOffUser(userid, regionid, regionhandle, new Vector3(posx, posy, posz), new Vector3());
540 // TODO: what is the logic should be?
541 bool ret = false;
542 ret = AddUserAgent(profile.CurrentAgent);
543 ret = ret & UpdateUserProfile(profile);
544 return ret;
545 } 541 }
546 542
547 #endregion 543 #endregion