From 38e8853e5761d09a7e8f580dd277d9b99b834696 Mon Sep 17 00:00:00 2001 From: Homer Horwitz Date: Sat, 1 Nov 2008 22:09:48 +0000 Subject: Megapatch that fixes/adds: friend offer/deny/accept, friendship termination, on-/offline updates, calling cards for friends. This adds methods in the DB layer and changes the MessagingServer, so a full update (incl. UGAIM) is necessary to get it working. Older regions shouldn't break, nor should older UGAIM break newer regions, but friends/presence will only work with all concerned parts (UGAIM, source region and destination region) at this revision (or later). I added the DB code for MSSQL, too, but couldn't test that. BEWARE: May contain bugs. --- .../Communications/OGS1/CommunicationsOGS1.cs | 4 +- .../Region/Communications/OGS1/OGS1GridServices.cs | 80 +++++++++++++++++++++- .../Region/Communications/OGS1/OGS1UserServices.cs | 60 +++++++++++++++- 3 files changed, 141 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Communications/OGS1') diff --git a/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs b/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs index d76f076..7f6fbc8 100644 --- a/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs +++ b/OpenSim/Region/Communications/OGS1/CommunicationsOGS1.cs @@ -56,7 +56,9 @@ namespace OpenSim.Region.Communications.OGS1 m_defaultInventoryHost = invService.Host; } - m_userService = new OGS1UserServices(this); + OGS1UserServices userServices = new OGS1UserServices(this); + m_userService = userServices; + m_messageService = userServices; m_avatarService = (IAvatarService)m_userService; } diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs index 32628f8..d9e0370 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs @@ -1785,5 +1785,83 @@ 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; + } + } } -} \ No newline at end of file +} diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs index 28177d0..595c4a9 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs @@ -39,7 +39,7 @@ using OpenSim.Framework.Communications; namespace OpenSim.Region.Communications.OGS1 { - public class OGS1UserServices : IUserService, IAvatarService + public class OGS1UserServices : IUserService, IAvatarService, IMessagingService { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -722,6 +722,64 @@ namespace OpenSim.Region.Communications.OGS1 return buddylist; } + public Dictionary GetFriendRegionInfos (List uuids) + { + Dictionary result = new Dictionary(); + + // ask MessageServer about the current on-/offline status and regions the friends are in + ArrayList parameters = new ArrayList(); + Hashtable map = new Hashtable(); + + ArrayList list = new ArrayList(); + foreach (UUID uuid in uuids) + { + list.Add(uuid.ToString()); + list.Add(uuid.ToString()); + } + map["uuids"] = list; + + map["recv_key"] = m_parent.NetworkServersInfo.UserRecvKey; + map["send_key"] = m_parent.NetworkServersInfo.UserRecvKey; + + parameters.Add(map); + + try { + XmlRpcRequest req = new XmlRpcRequest("get_presence_info_bulk", parameters); + XmlRpcResponse resp = req.Send(m_parent.NetworkServersInfo.MessagingURL, 8000); + Hashtable respData = (Hashtable) resp.Value; + + if (respData.ContainsKey("faultMessage")) + { + m_log.WarnFormat("[OGS1 USER SERVICES]: Contacting MessageServer about user-regions resulted in error: {0}", + respData["faultMessage"]); + } + else + { + int count = (int)respData["count"]; + m_log.DebugFormat("[OGS1 USER SERVICES]: Request returned {0} results.", count); + for (int i = 0; i < count; ++i) + { + UUID uuid; + if (UUID.TryParse((string)respData["uuid_" + i], out uuid)) + { + FriendRegionInfo info = new FriendRegionInfo(); + info.isOnline = (bool)respData["isOnline_" + i]; + if (info.isOnline) info.regionHandle = Convert.ToUInt64(respData["regionHandle_" + i]); + + result.Add(uuid, info); + } + } + } + } + catch (WebException e) + { + m_log.ErrorFormat("[OGS1 USER SERVICES]: Network problems when trying to fetch friend infos: {0}", e.Message); + } + + m_log.DebugFormat("[OGS1 USER SERVICES]: Returning {0} entries", result.Count); + return result; + } + #endregion /// Appearance -- cgit v1.1