aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/UserServer
diff options
context:
space:
mode:
authorMelanie Thielker2008-11-23 05:16:07 +0000
committerMelanie Thielker2008-11-23 05:16:07 +0000
commitcbd02218704287640ba5c7b564440a6590e038cf (patch)
treee600fd4868bce3e3d007d6d1894dd814d948692a /OpenSim/Grid/UserServer
parentMantis#2660. Thank you kindly, Ruud Lathrop for a patch that: (diff)
downloadopensim-SC-cbd02218704287640ba5c7b564440a6590e038cf.zip
opensim-SC-cbd02218704287640ba5c7b564440a6590e038cf.tar.gz
opensim-SC-cbd02218704287640ba5c7b564440a6590e038cf.tar.bz2
opensim-SC-cbd02218704287640ba5c7b564440a6590e038cf.tar.xz
Plumb in the presence notifications and region shutdown/restart messages
from the presence module to the message server, through the user server and on into the database. This should fix the "Already logged in" issue that grids see after a sim crashes, or a user crashes out of a sim. Not yet a 100% solution for friends, but getting there.
Diffstat (limited to 'OpenSim/Grid/UserServer')
-rw-r--r--OpenSim/Grid/UserServer/Main.cs29
-rw-r--r--OpenSim/Grid/UserServer/MessageServersConnector.cs93
-rw-r--r--OpenSim/Grid/UserServer/UserManager.cs47
3 files changed, 168 insertions, 1 deletions
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs
index eb47259..f894ca0 100644
--- a/OpenSim/Grid/UserServer/Main.cs
+++ b/OpenSim/Grid/UserServer/Main.cs
@@ -110,6 +110,11 @@ namespace OpenSim.Grid.UserServer
110 m_loginService.OnUserLoggedInAtLocation += NotifyMessageServersUserLoggedInToLocation; 110 m_loginService.OnUserLoggedInAtLocation += NotifyMessageServersUserLoggedInToLocation;
111 m_userManager.OnLogOffUser += NotifyMessageServersUserLoggOff; 111 m_userManager.OnLogOffUser += NotifyMessageServersUserLoggOff;
112 112
113 m_messagesService.OnAgentLocation += HandleAgentLocation;
114 m_messagesService.OnAgentLeaving += HandleAgentLeaving;
115 m_messagesService.OnRegionStartup += HandleRegionStartup;
116 m_messagesService.OnRegionShutdown += HandleRegionShutdown;
117
113 m_log.Info("[REGION]: Starting HTTP process"); 118 m_log.Info("[REGION]: Starting HTTP process");
114 119
115 m_httpServer = new BaseHttpServer(Cfg.HttpPort); 120 m_httpServer = new BaseHttpServer(Cfg.HttpPort);
@@ -147,6 +152,10 @@ namespace OpenSim.Grid.UserServer
147 m_httpServer.AddXmlRPCHandler("get_agent_by_uuid", m_userManager.XmlRPCGetAgentMethodUUID); 152 m_httpServer.AddXmlRPCHandler("get_agent_by_uuid", m_userManager.XmlRPCGetAgentMethodUUID);
148 m_httpServer.AddXmlRPCHandler("check_auth_session", m_userManager.XmlRPCCheckAuthSession); 153 m_httpServer.AddXmlRPCHandler("check_auth_session", m_userManager.XmlRPCCheckAuthSession);
149 m_httpServer.AddXmlRPCHandler("set_login_params", m_loginService.XmlRPCSetLoginParams); 154 m_httpServer.AddXmlRPCHandler("set_login_params", m_loginService.XmlRPCSetLoginParams);
155 m_httpServer.AddXmlRPCHandler("region_startup", m_messagesService.RegionStartup);
156 m_httpServer.AddXmlRPCHandler("region_shutdown", m_messagesService.RegionShutdown);
157 m_httpServer.AddXmlRPCHandler("agent_location", m_messagesService.AgentLocation);
158 m_httpServer.AddXmlRPCHandler("agent_leaving", m_messagesService.AgentLeaving);
150 // Message Server ---> User Server 159 // Message Server ---> User Server
151 m_httpServer.AddXmlRPCHandler("register_messageserver", m_messagesService.XmlRPCRegisterMessageServer); 160 m_httpServer.AddXmlRPCHandler("register_messageserver", m_messagesService.XmlRPCRegisterMessageServer);
152 m_httpServer.AddXmlRPCHandler("agent_change_region", m_messagesService.XmlRPCUserMovedtoRegion); 161 m_httpServer.AddXmlRPCHandler("agent_change_region", m_messagesService.XmlRPCUserMovedtoRegion);
@@ -442,5 +451,25 @@ namespace OpenSim.Grid.UserServer
442 m_messagesService.TellMessageServersAboutUser(agentID, sessionID, RegionID, regionhandle, positionX, 451 m_messagesService.TellMessageServersAboutUser(agentID, sessionID, RegionID, regionhandle, positionX,
443 positionY, positionZ, firstname, lastname); 452 positionY, positionZ, firstname, lastname);
444 } 453 }
454
455 public void HandleAgentLocation(UUID agentID, UUID regionID, ulong regionHandle)
456 {
457 m_userManager.HandleAgentLocation(agentID, regionID, regionHandle);
458 }
459
460 public void HandleAgentLeaving(UUID agentID, UUID regionID, ulong regionHandle)
461 {
462 m_userManager.HandleAgentLeaving(agentID, regionID, regionHandle);
463 }
464
465 public void HandleRegionStartup(UUID regionID)
466 {
467 m_userManager.HandleRegionStartup(regionID);
468 }
469
470 public void HandleRegionShutdown(UUID regionID)
471 {
472 m_userManager.HandleRegionShutdown(regionID);
473 }
445 } 474 }
446} 475}
diff --git a/OpenSim/Grid/UserServer/MessageServersConnector.cs b/OpenSim/Grid/UserServer/MessageServersConnector.cs
index 61f125e..6659617 100644
--- a/OpenSim/Grid/UserServer/MessageServersConnector.cs
+++ b/OpenSim/Grid/UserServer/MessageServersConnector.cs
@@ -57,7 +57,13 @@ namespace OpenSim.Grid.UserServer
57 public float positionZ; 57 public float positionZ;
58 public string firstname; 58 public string firstname;
59 public string lastname; 59 public string lastname;
60 }; 60 }
61
62 public delegate void AgentLocationDelegate(UUID agentID, UUID regionID, ulong regionHandle);
63 public delegate void AgentLeavingDelegate(UUID agentID, UUID regionID, ulong regionHandle);
64 public delegate void RegionStartupDelegate(UUID regionID);
65 public delegate void RegionShutdownDelegate(UUID regionID);
66
61 67
62 public class MessageServersConnector 68 public class MessageServersConnector
63 { 69 {
@@ -70,6 +76,11 @@ namespace OpenSim.Grid.UserServer
70 76
71 Thread m_NotifyThread; 77 Thread m_NotifyThread;
72 78
79 public event AgentLocationDelegate OnAgentLocation;
80 public event AgentLeavingDelegate OnAgentLeaving;
81 public event RegionStartupDelegate OnRegionStartup;
82 public event RegionShutdownDelegate OnRegionShutdown;
83
73 public MessageServersConnector() 84 public MessageServersConnector()
74 { 85 {
75 MessageServers = new Dictionary<string, MessageServerInfo>(); 86 MessageServers = new Dictionary<string, MessageServerInfo>();
@@ -337,5 +348,85 @@ namespace OpenSim.Grid.UserServer
337 } 348 }
338 } 349 }
339 } 350 }
351
352 public XmlRpcResponse RegionStartup(XmlRpcRequest request)
353 {
354 Hashtable requestData = (Hashtable)request.Params[0];
355 Hashtable result = new Hashtable();
356
357 UUID regionID;
358 if (UUID.TryParse((string)requestData["RegionUUID"], out regionID))
359 {
360 if (OnRegionStartup != null)
361 OnRegionStartup(regionID);
362
363 result["responsestring"] = "TRUE";
364 }
365
366 XmlRpcResponse response = new XmlRpcResponse();
367 response.Value = result;
368 return response;
369 }
370
371 public XmlRpcResponse RegionShutdown(XmlRpcRequest request)
372 {
373 Hashtable requestData = (Hashtable)request.Params[0];
374 Hashtable result = new Hashtable();
375
376 UUID regionID;
377 if (UUID.TryParse((string)requestData["RegionUUID"], out regionID))
378 {
379 if (OnRegionShutdown != null)
380 OnRegionShutdown(regionID);
381
382 result["responsestring"] = "TRUE";
383 }
384
385 XmlRpcResponse response = new XmlRpcResponse();
386 response.Value = result;
387 return response;
388 }
389
390 public XmlRpcResponse AgentLocation(XmlRpcRequest request)
391 {
392 Hashtable requestData = (Hashtable)request.Params[0];
393 Hashtable result = new Hashtable();
394
395 UUID agentID;
396 UUID regionID;
397 ulong regionHandle;
398 if (UUID.TryParse((string)requestData["AgentID"], out agentID) && UUID.TryParse((string)requestData["RegionUUID"], out regionID) && ulong.TryParse((string)requestData["RegionHandle"], out regionHandle))
399 {
400 if (OnAgentLocation != null)
401 OnAgentLocation(agentID, regionID, regionHandle);
402
403 result["responsestring"] = "TRUE";
404 }
405
406 XmlRpcResponse response = new XmlRpcResponse();
407 response.Value = result;
408 return response;
409 }
410
411 public XmlRpcResponse AgentLeaving(XmlRpcRequest request)
412 {
413 Hashtable requestData = (Hashtable)request.Params[0];
414 Hashtable result = new Hashtable();
415
416 UUID agentID;
417 UUID regionID;
418 ulong regionHandle;
419 if (UUID.TryParse((string)requestData["AgentID"], out agentID) && UUID.TryParse((string)requestData["RegionUUID"], out regionID) && ulong.TryParse((string)requestData["RegionHandle"], out regionHandle))
420 {
421 if (OnAgentLeaving != null)
422 OnAgentLeaving(agentID, regionID, regionHandle);
423
424 result["responsestring"] = "TRUE";
425 }
426
427 XmlRpcResponse response = new XmlRpcResponse();
428 response.Value = result;
429 return response;
430 }
340 } 431 }
341} 432}
diff --git a/OpenSim/Grid/UserServer/UserManager.cs b/OpenSim/Grid/UserServer/UserManager.cs
index f7e4e3c..04510b2 100644
--- a/OpenSim/Grid/UserServer/UserManager.cs
+++ b/OpenSim/Grid/UserServer/UserManager.cs
@@ -758,5 +758,52 @@ namespace OpenSim.Grid.UserServer
758 { 758 {
759 throw new Exception("The method or operation is not implemented."); 759 throw new Exception("The method or operation is not implemented.");
760 } 760 }
761
762 public void HandleAgentLocation(UUID agentID, UUID regionID, ulong regionHandle)
763 {
764 UserProfileData userProfile = GetUserProfile(agentID);
765 if (userProfile != null)
766 {
767 userProfile.CurrentAgent.Region = regionID;
768 userProfile.CurrentAgent.Handle = regionHandle;
769 CommitAgent(ref userProfile);
770 }
771 }
772
773 public void HandleAgentLeaving(UUID agentID, UUID regionID, ulong regionHandle)
774 {
775 UserProfileData userProfile = GetUserProfile(agentID);
776 if (userProfile != null)
777 {
778 if (userProfile.CurrentAgent.Region == regionID)
779 {
780 UserAgentData userAgent = userProfile.CurrentAgent;
781 if (userAgent != null && userAgent.AgentOnline)
782 {
783 userAgent.AgentOnline = false;
784 userAgent.LogoutTime = Util.UnixTimeSinceEpoch();
785 if (regionID != UUID.Zero)
786 {
787 userAgent.Region = regionID;
788 }
789 userAgent.Handle = regionHandle;
790 userProfile.LastLogin = userAgent.LogoutTime;
791
792 CommitAgent(ref userProfile);
793 }
794 }
795 }
796 }
797
798 public void HandleRegionStartup(UUID regionID)
799 {
800 LogoutUsers(regionID);
801 }
802
803 public void HandleRegionShutdown(UUID regionID)
804 {
805 LogoutUsers(regionID);
806 }
807
761 } 808 }
762} 809}