diff --git a/OpenSim/Grid/MessagingServer/Main.cs b/OpenSim/Grid/MessagingServer/Main.cs index 5568f73c64..0e03df1a49 100644 --- a/OpenSim/Grid/MessagingServer/Main.cs +++ b/OpenSim/Grid/MessagingServer/Main.cs @@ -90,6 +90,7 @@ namespace OpenSim.Grid.MessagingServer m_httpServer.AddXmlRPCHandler("get_presence_info_bulk", msgsvc.GetPresenceInfoBulk); m_httpServer.AddXmlRPCHandler("region_startup", msgsvc.RegionStartup); m_httpServer.AddXmlRPCHandler("region_shutdown", msgsvc.RegionShutdown); + m_httpServer.AddXmlRPCHandler("process_region_shutdown", msgsvc.ProcessRegionShutdown); m_httpServer.AddXmlRPCHandler("agent_location", msgsvc.AgentLocation); m_httpServer.AddXmlRPCHandler("agent_leaving", msgsvc.AgentLeaving); diff --git a/OpenSim/Grid/MessagingServer/MessageService.cs b/OpenSim/Grid/MessagingServer/MessageService.cs index a4e54c7918..a8ee9d51e6 100644 --- a/OpenSim/Grid/MessagingServer/MessageService.cs +++ b/OpenSim/Grid/MessagingServer/MessageService.cs @@ -666,5 +666,35 @@ namespace OpenSim.Grid.MessagingServer response.Value = result; return response; } + + public XmlRpcResponse ProcessRegionShutdown(XmlRpcRequest request) + { + Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable result = new Hashtable(); + result["success"] = "FALSE"; + + UUID regionID; + if (UUID.TryParse((string)requestData["regionid"], out regionID)) + { + m_log.DebugFormat("[PRESENCE] Processing region restart for {0}", regionID); + result["success"] = "TRUE"; + + foreach (UserPresenceData up in m_presences.Values) + { + if(up.regionData.UUID == regionID) + { + if (up.OnlineYN) + { + m_log.DebugFormat("[PRESENCE] Logging off {0} because the region they were in has gone", up.agentData.AgentID); + ProcessLogOff(up.agentData.AgentID); + } + } + } + } + + XmlRpcResponse response = new XmlRpcResponse(); + response.Value = result; + return response; + } } } diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs index f894ca0672..4e397aa9ce 100644 --- a/OpenSim/Grid/UserServer/Main.cs +++ b/OpenSim/Grid/UserServer/Main.cs @@ -464,12 +464,30 @@ namespace OpenSim.Grid.UserServer public void HandleRegionStartup(UUID regionID) { + // This might seem strange, that we send this back to the + // server it came from. But there is method to the madness. + // There can be multiple user servers on the same database, + // and each can have multiple messaging servers. So, we send + // it to all known user servers, who send it to all known + // message servers. That way, we should be able to finally + // update presence to all regions and thereby all friends + // m_userManager.HandleRegionStartup(regionID); + m_messagesService.TellMessageServersAboutRegionShutdown(regionID); } public void HandleRegionShutdown(UUID regionID) { + // This might seem strange, that we send this back to the + // server it came from. But there is method to the madness. + // There can be multiple user servers on the same database, + // and each can have multiple messaging servers. So, we send + // it to all known user servers, who send it to all known + // message servers. That way, we should be able to finally + // update presence to all regions and thereby all friends + // m_userManager.HandleRegionShutdown(regionID); + m_messagesService.TellMessageServersAboutRegionShutdown(regionID); } } } diff --git a/OpenSim/Grid/UserServer/MessageServersConnector.cs b/OpenSim/Grid/UserServer/MessageServersConnector.cs index 66596173f0..6da67d7faa 100644 --- a/OpenSim/Grid/UserServer/MessageServersConnector.cs +++ b/OpenSim/Grid/UserServer/MessageServersConnector.cs @@ -259,6 +259,25 @@ namespace OpenSim.Grid.UserServer } } + private void TellMessageServersAboutRegionShutdownInternal(UUID regionID) + { + lock (MessageServers) + { + if (MessageServers.Count > 0) + { + m_log.Info("[MSGCONNECTOR]: Sending region down notice to registered message servers"); + } + else + { +// m_log.Debug("[MSGCONNECTOR]: No Message Servers registered, ignoring"); + } + foreach (MessageServerInfo serv in MessageServers.Values) + { + NotifyMessageServerAboutRegionShutdown(serv,regionID); + } + } + } + public void TellMessageServersAboutUserLogoff(UUID agentID) { PresenceNotification notification = new PresenceNotification(); @@ -269,6 +288,16 @@ namespace OpenSim.Grid.UserServer m_NotifyQueue.Enqueue(notification); } + public void TellMessageServersAboutRegionShutdown(UUID regionID) + { + PresenceNotification notification = new PresenceNotification(); + + notification.request = NotificationRequest.Shutdown; + notification.RegionID = regionID; + + m_NotifyQueue.Enqueue(notification); + } + private void NotifyMessageServerAboutUserLogoff(MessageServerInfo serv, UUID agentID) { Hashtable reqparams = new Hashtable(); @@ -289,6 +318,26 @@ namespace OpenSim.Grid.UserServer m_log.Info("[LOGOUT]: Notified : " + serv.URI + " about user logout"); } + private void NotifyMessageServerAboutRegionShutdown(MessageServerInfo serv, UUID regionID) + { + Hashtable reqparams = new Hashtable(); + reqparams["sendkey"] = serv.sendkey; + reqparams["regionid"] = regionID.ToString(); + ArrayList SendParams = new ArrayList(); + SendParams.Add(reqparams); + + XmlRpcRequest GridReq = new XmlRpcRequest("process_region_shutdown", SendParams); + try + { + GridReq.Send(serv.URI, 6000); + } + catch (WebException) + { + m_log.Warn("[MSGCONNECTOR]: Unable to notify Message Server about region shutdown."); + } + m_log.Info("[REGION UPDOWN]: Notified : " + serv.URI + " about region state change"); + } + private void NotifyMessageServerAboutUser(MessageServerInfo serv, UUID agentID, UUID sessionID, UUID RegionID, ulong regionhandle, float positionX, float positionY, float positionZ, @@ -331,7 +380,9 @@ namespace OpenSim.Grid.UserServer PresenceNotification presence = m_NotifyQueue.Dequeue(); if (presence.request == NotificationRequest.Shutdown) - return; + { + TellMessageServersAboutRegionShutdownInternal(presence.RegionID); + } if (presence.request == NotificationRequest.Login) { diff --git a/OpenSim/Grid/UserServer/UserManager.cs b/OpenSim/Grid/UserServer/UserManager.cs index 04510b2b5a..f8f9f398e3 100644 --- a/OpenSim/Grid/UserServer/UserManager.cs +++ b/OpenSim/Grid/UserServer/UserManager.cs @@ -790,6 +790,10 @@ namespace OpenSim.Grid.UserServer userProfile.LastLogin = userAgent.LogoutTime; CommitAgent(ref userProfile); + + handlerLogOffUser = OnLogOffUser; + if (handlerLogOffUser != null) + handlerLogOffUser(agentID); } } }