From cbd02218704287640ba5c7b564440a6590e038cf Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sun, 23 Nov 2008 05:16:07 +0000 Subject: 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. --- .../Avatar/InstantMessage/PresenceModule.cs | 24 ++++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/PresenceModule.cs b/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/PresenceModule.cs index aa1db1d..7b358c2 100644 --- a/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/PresenceModule.cs +++ b/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/PresenceModule.cs @@ -114,10 +114,14 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage public void OnNewClient(IClientAPI client) { client.OnConnectionClosed += OnConnectionClosed; + client.OnLogout += OnConnectionClosed; } public void OnConnectionClosed(IClientAPI client) { + if (!(client.Scene is Scene)) + return; + if (!(m_RootAgents.ContainsKey(client.AgentId))) return; @@ -128,7 +132,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage m_RootAgents.Remove(client.AgentId); - NotifyMessageServerOfAgentLeaving(client.AgentId, scene.RegionInfo.RegionName); + NotifyMessageServerOfAgentLeaving(client.AgentId, scene.RegionInfo.RegionID, scene.RegionInfo.RegionHandle); } public void OnSetRootAgentScene(UUID agentID, Scene scene) @@ -139,13 +143,13 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage return; } m_RootAgents[agentID] = scene; - NotifyMessageServerOfAgentLocation(agentID, scene.RegionInfo.RegionName); + NotifyMessageServerOfAgentLocation(agentID, scene.RegionInfo.RegionID, scene.RegionInfo.RegionHandle); } private void NotifyMessageServerOfStartup(Scene scene) { Hashtable xmlrpcdata = new Hashtable(); - xmlrpcdata["RegionName"] = scene.RegionInfo.RegionName; + xmlrpcdata["RegionUUID"] = scene.RegionInfo.RegionID.ToString(); ArrayList SendParams = new ArrayList(); SendParams.Add(xmlrpcdata); try @@ -154,7 +158,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage XmlRpcResponse resp = UpRequest.Send(scene.CommsManager.NetworkServersInfo.MessagingURL, 5000); Hashtable responseData = (Hashtable)resp.Value; - if ((!responseData.ContainsKey("success")) || (string)responseData["success"] != "TRUE") + if (responseData == null || (!responseData.ContainsKey("success")) || (string)responseData["success"] != "TRUE") { m_log.ErrorFormat("[PRESENCE] Failed to notify message server of region startup for region {0}", scene.RegionInfo.RegionName); } @@ -168,7 +172,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage private void NotifyMessageServerOfShutdown(Scene scene) { Hashtable xmlrpcdata = new Hashtable(); - xmlrpcdata["RegionName"] = scene.RegionInfo.RegionName; + xmlrpcdata["RegionUUID"] = scene.RegionInfo.RegionID.ToString(); ArrayList SendParams = new ArrayList(); SendParams.Add(xmlrpcdata); try @@ -188,11 +192,12 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage } } - private void NotifyMessageServerOfAgentLocation(UUID agentID, string region) + private void NotifyMessageServerOfAgentLocation(UUID agentID, UUID region, ulong regionHandle) { Hashtable xmlrpcdata = new Hashtable(); xmlrpcdata["AgentID"] = agentID.ToString(); - xmlrpcdata["RegionName"] = region; + xmlrpcdata["RegionUUID"] = region.ToString(); + xmlrpcdata["RegionHandle"] = regionHandle.ToString(); ArrayList SendParams = new ArrayList(); SendParams.Add(xmlrpcdata); try @@ -212,11 +217,12 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage } } - private void NotifyMessageServerOfAgentLeaving(UUID agentID, string region) + private void NotifyMessageServerOfAgentLeaving(UUID agentID, UUID region, ulong regionHandle) { Hashtable xmlrpcdata = new Hashtable(); xmlrpcdata["AgentID"] = agentID.ToString(); - xmlrpcdata["RegionName"] = region; + xmlrpcdata["RegionUUID"] = region.ToString(); + xmlrpcdata["RegionHandle"] = regionHandle.ToString(); ArrayList SendParams = new ArrayList(); SendParams.Add(xmlrpcdata); try -- cgit v1.1