From e725e485fa72bcdba03df9ed7d0b007b6e548eb3 Mon Sep 17 00:00:00 2001 From: diva Date: Fri, 20 Feb 2009 00:18:18 +0000 Subject: This moves the 2 friends-related interregion messages out of OGS1 and into the FriendsModule. No functional changes. Those messages were sent over XMLRPC, and that's how it continues to be for now. Just moving this couple of interregion messages out of OGS1, in preparation for the big shlep ahead. --- .../Communications/CommunicationsManager.cs | 10 --- .../Communications/IInterRegionCommunications.cs | 36 -------- .../Region/Communications/OGS1/OGS1GridServices.cs | 78 ------------------ .../CoreModules/Avatar/Friends/FriendsModule.cs | 96 +++++++++++++++++++++- OpenSim/Region/Framework/Scenes/Scene.cs | 10 --- 5 files changed, 94 insertions(+), 136 deletions(-) diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index 936e583..e0e07b2 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -324,16 +324,6 @@ namespace OpenSim.Framework.Communications return m_messageService.GetFriendRegionInfos(uuids); } - public List InformFriendsInOtherRegion(UUID agentId, ulong destRegionHandle, List friends, bool online) - { - return m_interRegion.InformFriendsInOtherRegion(agentId, destRegionHandle, friends, online); - } - - public bool TriggerTerminateFriend(ulong regionHandle, UUID agentID, UUID exFriendID) - { - return m_interRegion.TriggerTerminateFriend(regionHandle, agentID, exFriendID); - } - #endregion #region Packet Handlers diff --git a/OpenSim/Framework/Communications/IInterRegionCommunications.cs b/OpenSim/Framework/Communications/IInterRegionCommunications.cs index 6b589b9..2d4eb53 100644 --- a/OpenSim/Framework/Communications/IInterRegionCommunications.cs +++ b/OpenSim/Framework/Communications/IInterRegionCommunications.cs @@ -48,41 +48,5 @@ namespace OpenSim.Framework.Communications bool TellRegionToCloseChildConnection(ulong regionHandle, UUID agentID); - /// - /// Try to inform friends in the given region about online status of agent. - /// - /// - /// The of the agent. - /// - /// - /// The regionHandle of the region. - /// - /// - /// A List of s of friends to inform in the given region. - /// - /// - /// Is the agent online or offline - /// - /// - /// A list of friends that couldn't be reached on this region. - /// - List InformFriendsInOtherRegion(UUID agentId, ulong destRegionHandle, List friends, bool online); - - /// - /// Send TerminateFriend of exFriendID to agent agentID in region regionHandle. - /// - /// - /// The handle of the region agentID is in (hopefully). - /// - /// - /// The agent to send the packet to. - /// - /// - /// The ex-friends ID. - /// - /// - /// Whether the packet could be sent. False if the agent couldn't be found in the region. - /// - bool TriggerTerminateFriend(ulong regionHandle, UUID agentID, UUID exFriendID); } } diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs index 1da7621..660e684 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs @@ -1810,83 +1810,5 @@ namespace OpenSim.Region.Communications.OGS1 return null; } } - - public List InformFriendsInOtherRegion(UUID agentId, ulong destRegionHandle, List friends, bool online) - { - List tpdAway = new List(); - - // destRegionHandle is a region on another server - RegionInfo info = RequestNeighbourInfo(destRegionHandle); - if (info != null) - { - string httpServer = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/presence_update_bulk"; - - Hashtable reqParams = new Hashtable(); - reqParams["agentID"] = agentId.ToString(); - reqParams["agentOnline"] = online; - int count = 0; - foreach (UUID uuid in friends) - { - reqParams["friendID_" + count++] = uuid.ToString(); - } - reqParams["friendCount"] = count; - - IList parameters = new ArrayList(); - parameters.Add(reqParams); - try - { - XmlRpcRequest request = new XmlRpcRequest("presence_update_bulk", parameters); - XmlRpcResponse response = request.Send(httpServer, 5000); - Hashtable respData = (Hashtable)response.Value; - - count = (int)respData["friendCount"]; - for (int i = 0; i < count; ++i) - { - UUID uuid; - if (UUID.TryParse((string)respData["friendID_" + i], out uuid)) tpdAway.Add(uuid); - } - } - catch (Exception e) - { - m_log.Error("[OGS1 GRID SERVICES]: InformFriendsInOtherRegion XMLRPC failure: ", e); - } - } - else m_log.WarnFormat("[OGS1 GRID SERVICES]: Couldn't find region {0}???", destRegionHandle); - - return tpdAway; - } - - public bool TriggerTerminateFriend(ulong destRegionHandle, UUID agentID, UUID exFriendID) - { - // destRegionHandle is a region on another server - RegionInfo info = RequestNeighbourInfo(destRegionHandle); - if (info == null) - { - m_log.WarnFormat("[OGS1 GRID SERVICES]: Couldn't find region {0}", destRegionHandle); - return false; // region not found??? - } - - string httpServer = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/presence_update_bulk"; - - Hashtable reqParams = new Hashtable(); - reqParams["agentID"] = agentID.ToString(); - reqParams["friendID"] = exFriendID.ToString(); - - IList parameters = new ArrayList(); - parameters.Add(reqParams); - try - { - XmlRpcRequest request = new XmlRpcRequest("terminate_friend", parameters); - XmlRpcResponse response = request.Send(httpServer, 5000); - Hashtable respData = (Hashtable)response.Value; - - return (bool)respData["success"]; - } - catch (Exception e) - { - m_log.Error("[OGS1 GRID SERVICES]: InformFriendsInOtherRegion XMLRPC failure: ", e); - return false; - } - } } } diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index f23f4e0..d91e10d 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -34,6 +34,7 @@ using Nini.Config; using Nwc.XmlRpc; using OpenMetaverse; using OpenSim.Framework; +using OpenSim.Framework.Communications; using OpenSim.Framework.Communications.Cache; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; @@ -105,6 +106,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends private Dictionary m_scenes = new Dictionary(); private IMessageTransferModule m_TransferModule = null; + private IGridServices m_gridServices = null; + #region IRegionModule Members public void Initialise(Scene scene, IConfigSource config) @@ -137,6 +140,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends if (m_scenes.Count > 0) { m_TransferModule = m_initialScene.RequestModuleInterface(); + m_gridServices = m_initialScene.CommsManager.GridService; } if (m_TransferModule == null) m_log.Error("[FRIENDS]: Unable to find a message transfer module, friendship offers will not work"); @@ -158,6 +162,89 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends #endregion + #region IInterregionFriendsComms + + public List InformFriendsInOtherRegion(UUID agentId, ulong destRegionHandle, List friends, bool online) + { + List tpdAway = new List(); + + // destRegionHandle is a region on another server + RegionInfo info = m_gridServices.RequestNeighbourInfo(destRegionHandle); + if (info != null) + { + string httpServer = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/presence_update_bulk"; + + Hashtable reqParams = new Hashtable(); + reqParams["agentID"] = agentId.ToString(); + reqParams["agentOnline"] = online; + int count = 0; + foreach (UUID uuid in friends) + { + reqParams["friendID_" + count++] = uuid.ToString(); + } + reqParams["friendCount"] = count; + + IList parameters = new ArrayList(); + parameters.Add(reqParams); + try + { + XmlRpcRequest request = new XmlRpcRequest("presence_update_bulk", parameters); + XmlRpcResponse response = request.Send(httpServer, 5000); + Hashtable respData = (Hashtable)response.Value; + + count = (int)respData["friendCount"]; + for (int i = 0; i < count; ++i) + { + UUID uuid; + if (UUID.TryParse((string)respData["friendID_" + i], out uuid)) tpdAway.Add(uuid); + } + } + catch (Exception e) + { + m_log.Error("[OGS1 GRID SERVICES]: InformFriendsInOtherRegion XMLRPC failure: ", e); + } + } + else m_log.WarnFormat("[OGS1 GRID SERVICES]: Couldn't find region {0}???", destRegionHandle); + + return tpdAway; + } + + public bool TriggerTerminateFriend(ulong destRegionHandle, UUID agentID, UUID exFriendID) + { + // destRegionHandle is a region on another server + RegionInfo info = m_gridServices.RequestNeighbourInfo(destRegionHandle); + if (info == null) + { + m_log.WarnFormat("[OGS1 GRID SERVICES]: Couldn't find region {0}", destRegionHandle); + return false; // region not found??? + } + + string httpServer = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/presence_update_bulk"; + + Hashtable reqParams = new Hashtable(); + reqParams["agentID"] = agentID.ToString(); + reqParams["friendID"] = exFriendID.ToString(); + + IList parameters = new ArrayList(); + parameters.Add(reqParams); + try + { + XmlRpcRequest request = new XmlRpcRequest("terminate_friend", parameters); + XmlRpcResponse response = request.Send(httpServer, 5000); + Hashtable respData = (Hashtable)response.Value; + + return (bool)respData["success"]; + } + catch (Exception e) + { + m_log.Error("[OGS1 GRID SERVICES]: InformFriendsInOtherRegion XMLRPC failure: ", e); + return false; + } + } + + #endregion + + #region Incoming XMLRPC messages /// /// Receive presence information changes about clients in other regions. /// @@ -264,6 +351,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends return response; } + #endregion + + #region Scene events + private void OnNewClient(IClientAPI client) { // All friends establishment protocol goes over instant message @@ -331,6 +422,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends } } } + #endregion private ScenePresence GetRootPresenceFromAgentID(UUID AgentID) { @@ -681,7 +773,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends agentID, exfriendID, data.Handle); // try to send to foreign region, retry if it fails (friend TPed away, for example) - if (m_initialScene.TriggerTerminateFriend(data.Handle, exfriendID, agentID)) break; + if (TriggerTerminateFriend(data.Handle, exfriendID, agentID)) break; } } @@ -942,7 +1034,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends //m_log.DebugFormat("[FRIEND]: Inform {0} friends in region {1} that user {2} is {3}line", // pair.Value.Count, pair.Key, client.Name, iAmOnline ? "on" : "off"); - friendIDsToSendTo.AddRange(m_initialScene.InformFriendsInOtherRegion(client.AgentId, pair.Key, pair.Value, iAmOnline)); + friendIDsToSendTo.AddRange(InformFriendsInOtherRegion(client.AgentId, pair.Key, pair.Value, iAmOnline)); } } // now we have in friendIDsToSendTo only the agents left that TPed away while we tried to contact them. diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 23c4478..1f6d647 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2743,16 +2743,6 @@ namespace OpenSim.Region.Framework.Scenes return CommsManager.GetFriendRegionInfos(uuids); } - public List InformFriendsInOtherRegion(UUID agentId, ulong destRegionHandle, List friends, bool online) - { - return CommsManager.InformFriendsInOtherRegion(agentId, destRegionHandle, friends, online); - } - - public bool TriggerTerminateFriend(ulong regionHandle, UUID agentID, UUID exFriendID) - { - return CommsManager.TriggerTerminateFriend(regionHandle, agentID, exFriendID); - } - public virtual void StoreAddFriendship(UUID ownerID, UUID friendID, uint perms) { m_sceneGridService.AddNewUserFriend(ownerID, friendID, perms); -- cgit v1.1