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.
0.6.0-stable
Homer Horwitz 2008-11-01 22:09:48 +00:00
parent e3a1ccf0b2
commit 38e8853e57
32 changed files with 1402 additions and 754 deletions

View File

@ -570,6 +570,39 @@ namespace OpenSim.Data.MSSQL
return friendList;
}
override public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos (List<UUID> uuids)
{
Dictionary<UUID, FriendRegionInfo> infos = new Dictionary<UUID,FriendRegionInfo>();
try
{
foreach (UUID uuid in uuids)
{
using (AutoClosingSqlCommand command = database.Query(
"select agentOnline,currentHandle from " + m_agentsTableName + " where UUID = @uuid"))
{
command.Parameters.Add(database.CreateParameter("@uuid", uuid));
using (IDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
FriendRegionInfo fri = new FriendRegionInfo();
fri.isOnline = (sbyte)reader["agentOnline"] != 0;
fri.regionHandle = (ulong)reader["currentHandle"];
infos[uuid] = fri;
}
}
}
}
}
catch (Exception e)
{
m_log.Warn("[MSSQL]: Got exception on trying to find friends regions:", e);
}
return infos;
}
#endregion
#region Money functions (not used)

View File

@ -365,6 +365,49 @@ namespace OpenSim.Data.MySQL
return Lfli;
}
override public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos (List<UUID> uuids)
{
MySQLSuperManager dbm = GetLockedConnection("GetFriendRegionInfos");
Dictionary<UUID, FriendRegionInfo> infos = new Dictionary<UUID,FriendRegionInfo>();
try
{
foreach (UUID uuid in uuids)
{
Dictionary<string, string> param = new Dictionary<string, string>();
param["?uuid"] = uuid.ToString();
IDbCommand result =
dbm.Manager.Query("select agentOnline,currentHandle from " + m_agentsTableName +
" where UUID = ?uuid", param);
IDataReader reader = result.ExecuteReader();
while (reader.Read())
{
FriendRegionInfo fri = new FriendRegionInfo();
fri.isOnline = (sbyte)reader["agentOnline"] != 0;
fri.regionHandle = (ulong)reader["currentHandle"];
infos[uuid] = fri;
}
reader.Dispose();
result.Dispose();
}
}
catch (Exception e)
{
m_log.Warn("[MYSQL]: Got exception on trying to find friends regions:", e);
dbm.Manager.Reconnect();
m_log.Error(e.ToString());
}
finally
{
dbm.Release();
}
return infos;
}
#endregion
public override void UpdateUserCurrentRegion(UUID avatarid, UUID regionuuid, ulong regionhandle)

View File

@ -255,6 +255,7 @@ namespace OpenSim.Data.NHibernate
public override void RemoveUserFriend(UUID friendlistowner, UUID friend) { return; }
public override void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) { return; }
public override List<FriendListItem> GetUserFriendList(UUID friendlistowner) { return new List<FriendListItem>(); }
public override Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos (List<UUID> uuids) { return new Dictionary<UUID, FriendRegionInfo>(); }
public override bool MoneyTransferRequest(UUID from, UUID to, uint amount) { return true; }
public override bool InventoryTransferRequest(UUID from, UUID to, UUID inventory) { return true; }

View File

@ -332,8 +332,28 @@ namespace OpenSim.Data.SQLite
return returnlist;
}
override public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos (List<UUID> uuids)
{
Dictionary<UUID, FriendRegionInfo> infos = new Dictionary<UUID,FriendRegionInfo>();
DataTable agents = ds.Tables["useragents"];
foreach (UUID uuid in uuids)
{
lock (ds)
{
DataRow row = agents.Rows.Find(Util.ToRawUuidString(uuid));
if (row == null) infos[uuid] = null;
else
{
FriendRegionInfo fri = new FriendRegionInfo();
fri.isOnline = (bool)row["agentOnline"];
fri.regionHandle = Convert.ToUInt64(row["currentHandle"]);
infos[uuid] = fri;
}
}
}
return infos;
}
#endregion

View File

@ -53,6 +53,7 @@ namespace OpenSim.Data
public abstract void RemoveUserFriend(UUID friendlistowner, UUID friend);
public abstract void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms);
public abstract List<FriendListItem> GetUserFriendList(UUID friendlistowner);
public abstract Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos (List<UUID> uuids);
public abstract bool MoneyTransferRequest(UUID from, UUID to, uint amount);
public abstract bool InventoryTransferRequest(UUID from, UUID to, UUID inventory);
public abstract List<AvatarPickerAvatar> GeneratePickerResults(UUID queryID, string query);

View File

@ -50,6 +50,12 @@ namespace OpenSim.Framework.Communications
}
protected IUserService m_userService;
public IMessagingService MessageService
{
get { return m_messageService; }
}
protected IMessagingService m_messageService;
public IGridServices GridService
{
get { return m_gridService; }
@ -370,6 +376,21 @@ namespace OpenSim.Framework.Communications
return m_userService.GetUserFriendList(friendlistowner);
}
public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos(List<UUID> uuids)
{
return m_messageService.GetFriendRegionInfos(uuids);
}
public List<UUID> InformFriendsInOtherRegion(UUID agentId, ulong destRegionHandle, List<UUID> 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

View File

@ -25,6 +25,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System.Collections.Generic;
using OpenMetaverse;
namespace OpenSim.Framework.Communications
@ -46,5 +47,42 @@ namespace OpenSim.Framework.Communications
bool AcknowledgePrimCrossed(ulong regionHandle, UUID primID);
bool TellRegionToCloseChildConnection(ulong regionHandle, UUID agentID);
/// <summary>
/// Try to inform friends in the given region about online status of agent.
/// </summary>
/// <param name="agentId">
/// The <see cref="UUID"/> of the agent.
/// </param>
/// <param name="destRegionHandle">
/// The regionHandle of the region.
/// </param>
/// <param name="friends">
/// A List of <see cref="UUID"/>s of friends to inform in the given region.
/// </param>
/// <param name="online">
/// Is the agent online or offline
/// </param>
/// <returns>
/// A list of friends that couldn't be reached on this region.
/// </returns>
List<UUID> InformFriendsInOtherRegion(UUID agentId, ulong destRegionHandle, List<UUID> friends, bool online);
/// <summary>
/// Send TerminateFriend of exFriendID to agent agentID in region regionHandle.
/// </summary>
/// <param name="regionHandle">
/// The handle of the region agentID is in (hopefully).
/// </param>
/// <param name="agentID">
/// The agent to send the packet to.
/// </param>
/// <param name="exFriendID">
/// The ex-friends ID.
/// </param>
/// <returns>
/// Whether the packet could be sent. False if the agent couldn't be found in the region.
/// </returns>
bool TriggerTerminateFriend(ulong regionHandle, UUID agentID, UUID exFriendID);
}
}

View File

@ -0,0 +1,37 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System.Collections.Generic;
using OpenMetaverse;
namespace OpenSim.Framework.Communications
{
public interface IMessagingService
{
Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos (List<UUID> uuids);
}
}

View File

@ -35,6 +35,7 @@ using OpenMetaverse;
using OpenMetaverse.StructuredData;
using log4net;
using Nwc.XmlRpc;
using OpenSim.Framework;
using OpenSim.Framework.Statistics;
namespace OpenSim.Framework.Communications
@ -42,7 +43,7 @@ namespace OpenSim.Framework.Communications
/// <summary>
/// Base class for user management (create, read, etc)
/// </summary>
public abstract class UserManagerBase : IUserService, IUserServiceAdmin, IAvatarService
public abstract class UserManagerBase : IUserService, IUserServiceAdmin, IAvatarService, IMessagingService
{
private static readonly ILog m_log
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@ -285,6 +286,27 @@ namespace OpenSim.Framework.Communications
return null;
}
public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos (List<UUID> uuids)
{
foreach (IUserDataPlugin plugin in _plugins)
{
try
{
Dictionary<UUID, FriendRegionInfo> result = plugin.GetFriendRegionInfos(uuids);
if (result != null)
{
return result;
}
}
catch (Exception e)
{
m_log.Info("[USERSTORAGE]: Unable to GetFriendRegionInfos via " + plugin.Name + "(" + e.ToString() + ")");
}
}
return null;
}
public void StoreWebLoginKey(UUID agentID, UUID webLoginKey)
{
foreach (IUserDataPlugin plugin in _plugins)

View File

@ -35,9 +35,9 @@ namespace OpenSim.Framework
public UUID FriendListOwner;
// These are what the list owner gives the friend permission to do
public uint FriendListOwnerPerms;
// These are what the friend gives the listowner permission to do
public uint FriendListOwnerPerms;
public uint FriendPerms;
public bool onlinestatus = false;

View File

@ -0,0 +1,37 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
namespace OpenSim.Framework
{
public class FriendRegionInfo
{
public bool isOnline;
public ulong regionHandle;
}
}

View File

@ -925,6 +925,8 @@ namespace OpenSim.Framework
void SendAcceptCallingCard(UUID transactionID);
void SendDeclineCallingCard(UUID transactionID);
void SendTerminateFriend(UUID exFriendID);
void KillEndDone();
}
}

View File

@ -135,6 +135,17 @@ namespace OpenSim.Framework
/// <param name="friendlistowner">The agent that we're retreiving the friends Data.</param>
List<FriendListItem> GetUserFriendList(UUID friendlistowner);
/// <summary>
/// Returns a list of <see cref="FriendRegionInfo/>s for the specified UUIDs.
/// </summary>
/// <param name="uuids">
/// A <see cref="List"/> of <see cref="UUID/>s to fetch info for
/// </param>
/// <returns>
/// A <see cref="Dictionary"/>, mapping the <see cref="UUID"/>s to <see cref="FriendRegionInfo"/>s.
/// </returns>
Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos(List<UUID> uuids);
/// <summary>
/// Attempts to move currency units between accounts (NOT RELIABLE / TRUSTWORTHY. DONT TRY RUN YOUR OWN CURRENCY EXCHANGE WITH REAL VALUES)
/// </summary>

View File

@ -53,6 +53,7 @@ namespace OpenSim.Framework
public string HttpSSLCN = "";
public uint httpSSLPort = 9001;
public string MessagingURL = String.Empty;
public NetworkServersInfo()
{
@ -102,6 +103,9 @@ namespace OpenSim.Framework
"http://127.0.0.1:" +
InventoryConfig.DefaultHttpPort.ToString());
secureInventoryServer = config.Configs["Network"].GetBoolean("secure_inventory_server", true);
MessagingURL = config.Configs["Network"].GetString("messaging_server_url",
"http://127.0.0.1:" + MessageServerConfig.DefaultHttpPort);
}
}
}

View File

@ -585,8 +585,19 @@ namespace OpenSim.Framework.Servers
XmlRpcMethod method;
if (m_rpcHandlers.TryGetValue(methodName, out method))
{
try
{
xmlRpcResponse = method(xmlRprcRequest);
}
catch(Exception e)
{
// if the registered XmlRpc method threw an exception, we pass a fault-code along
xmlRpcResponse = new XmlRpcResponse();
// Code probably set in accordance with http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php
xmlRpcResponse.SetFault(-32603, String.Format("Requested method [{0}] threw exception: {1}",
methodName, e.Message));
}
// if the method wasn't found, we can't determine KeepAlive state anyway, so lets do it only here
response.KeepAlive = m_rpcHandlersKeepAlive[methodName];
}

View File

@ -87,6 +87,7 @@ namespace OpenSim.Grid.MessagingServer
m_httpServer.AddXmlRPCHandler("login_to_simulator", msgsvc.UserLoggedOn);
m_httpServer.AddXmlRPCHandler("logout_of_simulator", msgsvc.UserLoggedOff);
m_httpServer.AddXmlRPCHandler("get_presence_info_bulk", msgsvc.GetPresenceInfoBulk);
m_httpServer.Start();
m_log.Info("[SERVER]: Userserver registration was successful");

View File

@ -37,8 +37,6 @@ using Nwc.XmlRpc;
using OpenSim.Data;
using OpenSim.Framework;
//using System.Xml;
namespace OpenSim.Grid.MessagingServer
{
public class MessageService
@ -48,17 +46,11 @@ namespace OpenSim.Grid.MessagingServer
private MessageServerConfig m_cfg;
private UserManager m_userManager;
//A hashtable of all current presences this server knows about
private Hashtable m_presences = new Hashtable();
// a dictionary of all current presences this server knows about
private Dictionary<UUID, UserPresenceData> m_presences = new Dictionary<UUID,UserPresenceData>();
//a hashtable of all current regions this server knows about
private Hashtable m_regionInfoCache = new Hashtable();
//A hashtable containing lists of UUIDs keyed by UUID for fast backreferencing
private Hashtable m_presence_BackReferences = new Hashtable();
// Hashtable containing work units that need to be processed
// private Hashtable m_unProcessedWorkUnits = new Hashtable();
// a dictionary of all current regions this server knows about
private Dictionary<ulong, RegionProfileData> m_regionInfoCache = new Dictionary<ulong,RegionProfileData>();
public MessageService(MessageServerConfig cfg)
{
@ -78,30 +70,60 @@ namespace OpenSim.Grid.MessagingServer
/// Process Friendlist subscriptions for a user
/// The login method calls this for a User
/// </summary>
/// <param name="userpresence">The Agent we're processing the friendlist subscriptions</param>
public void ProcessFriendListSubscriptions(UserPresenceData userpresence)
/// <param name="userpresence">The Agent we're processing the friendlist subscriptions for</param>
private void ProcessFriendListSubscriptions(UserPresenceData userpresence)
{
lock (m_presences)
{
if (!m_presences.Contains(userpresence.agentData.AgentID))
m_presences.Add(userpresence.agentData.AgentID, userpresence);
else
m_presences[userpresence.agentData.AgentID] = userpresence;
}
List<FriendListItem> uFriendList = userpresence.friendData;
for (int i = 0; i < uFriendList.Count; i++)
Dictionary<UUID, FriendListItem> uFriendList = userpresence.friendData;
foreach (KeyValuePair<UUID, FriendListItem> pair in uFriendList)
{
//m_presence_BackReferences.Add(userpresence.agentData.AgentID, uFriendList[i].Friend);
// m_presence_BackReferences.Add(uFriendList[i].Friend, userpresence.agentData.AgentID);
if (m_presences.Contains(uFriendList[i].Friend))
UserPresenceData friendup = null;
lock (m_presences)
{
UserPresenceData friendup = (UserPresenceData)m_presences[uFriendList[i].Friend];
// Add backreference
SubscribeToPresenceUpdates(userpresence, friendup, uFriendList[i],i);
m_presences.TryGetValue(pair.Key, out friendup);
}
if (friendup != null)
{
SubscribeToPresenceUpdates(userpresence, friendup, pair.Value);
}
}
}
/// <summary>
/// Enqueues a presence update, sending info about user 'talkingAbout' to user 'receiver'.
/// </summary>
/// <param name="talkingAbout">We are sending presence information about this user.</param>
/// <param name="receiver">We are sending the presence update to this user</param>
private void enqueuePresenceUpdate(UserPresenceData talkingAbout, UserPresenceData receiver)
{
UserAgentData p2Handle = m_userManager.GetUserAgentData(receiver.agentData.AgentID);
if (p2Handle != null)
{
if (receiver.lookupUserRegionYN)
{
receiver.regionData.regionHandle = p2Handle.Handle;
}
else
{
receiver.lookupUserRegionYN = true; // TODO Huh?
}
PresenceInformer friendlistupdater = new PresenceInformer();
friendlistupdater.presence1 = talkingAbout;
friendlistupdater.presence2 = receiver;
friendlistupdater.OnGetRegionData += GetRegionInfo;
friendlistupdater.OnDone += PresenceUpdateDone;
WaitCallback cb = new WaitCallback(friendlistupdater.go);
ThreadPool.QueueUserWorkItem(cb);
}
else
{
m_log.WarnFormat("no data found for user {0}", receiver.agentData.AgentID);
// Skip because we can't find any data on the user
}
}
@ -113,139 +135,34 @@ namespace OpenSim.Grid.MessagingServer
/// <param name="userpresence">P1</param>
/// <param name="friendpresence">P2</param>
/// <param name="uFriendListItem"></param>
/// <param name="uFriendListIndex"></param>
public void SubscribeToPresenceUpdates(UserPresenceData userpresence, UserPresenceData friendpresence,
FriendListItem uFriendListItem, int uFriendListIndex)
private void SubscribeToPresenceUpdates(UserPresenceData userpresence,
UserPresenceData friendpresence,
FriendListItem uFriendListItem)
{
// Can the friend see me online?
if ((uFriendListItem.FriendListOwnerPerms & (uint)FriendRights.CanSeeOnline) != 0)
{
// Subscribe and Send Out updates
if (!friendpresence.subscriptionData.Contains(friendpresence.agentData.AgentID))
// tell user to update friend about user's presence changes
if (!userpresence.subscriptionData.Contains(friendpresence.agentData.AgentID))
{
userpresence.subscriptionData.Add(friendpresence.agentData.AgentID);
//Send Region Notice....
}
else
{
// we need to send out online status update, but the user is already subscribed
}
UserAgentData p2Handle = m_userManager.GetUserAgentData(userpresence.agentData.AgentID);
if (p2Handle != null)
{
if (userpresence.lookupUserRegionYN)
{
userpresence.regionData.regionHandle = p2Handle.Handle;
}
else
{
userpresence.lookupUserRegionYN = true;
}
PresenceInformer friendlistupdater = new PresenceInformer();
friendlistupdater.presence1 = friendpresence;
//friendlistupdater.gridserverurl = m_cfg.GridServerURL;
//friendlistupdater.gridserversendkey = m_cfg.GridSendKey;
//friendlistupdater.gridserverrecvkey = m_cfg.GridRecvKey;
friendlistupdater.presence2 = userpresence;
friendlistupdater.OnGetRegionData += GetRegionInfo;
friendlistupdater.OnDone += PresenceUpdateDone;
WaitCallback cb = new WaitCallback(friendlistupdater.go);
ThreadPool.QueueUserWorkItem(cb);
}
else
{
// Skip because we can't find any data on the user
}
//SendRegionPresenceUpdate(friendpresence, userpresence);
// send an update about user's presence to the friend
enqueuePresenceUpdate(userpresence, friendpresence);
}
// Can I see the friend online?
if ((uFriendListItem.FriendPerms & (uint)FriendRights.CanSeeOnline) != 0)
{
// tell friend to update user about friend's presence changes
if (!friendpresence.subscriptionData.Contains(userpresence.agentData.AgentID))
{
friendpresence.subscriptionData.Add(userpresence.agentData.AgentID);
//Send Region Notice....
}
else
{
// we need to send out online status update, but the user is already subscribed
}
UserAgentData p2Handle = m_userManager.GetUserAgentData(friendpresence.agentData.AgentID);
if (p2Handle != null)
{
friendpresence.regionData.regionHandle = p2Handle.Handle;
PresenceInformer friendlistupdater = new PresenceInformer();
friendlistupdater.presence1 = userpresence;
friendlistupdater.presence2 = friendpresence;
//friendlistupdater.gridserverurl = m_cfg.GridServerURL;
//friendlistupdater.gridserversendkey = m_cfg.GridSendKey;
//friendlistupdater.gridserverrecvkey = m_cfg.GridRecvKey;
friendlistupdater.OnGetRegionData += GetRegionInfo;
friendlistupdater.OnDone += PresenceUpdateDone;
WaitCallback cb2 = new WaitCallback(friendlistupdater.go);
ThreadPool.QueueUserWorkItem(cb2);
}
else
{
// skip, agent doesn't appear to exist anymore
}
//SendRegionPresenceUpdate(userpresence, friendpresence);
}
}
/// <summary>
/// Adds a backreference so presence specific data doesn't have to be
/// enumerated for each logged in user every time someone logs on or off.
/// </summary>
/// <param name="agentID"></param>
/// <param name="friendID"></param>
public void addBackReference(UUID agentID, UUID friendID)
{
if (m_presence_BackReferences.Contains(friendID))
{
List<UUID> presenseBackReferences = (List<UUID>)m_presence_BackReferences[friendID];
if (!presenseBackReferences.Contains(agentID))
{
presenseBackReferences.Add(agentID);
}
m_presence_BackReferences[friendID] = presenseBackReferences;
}
else
{
List<UUID> presenceBackReferences = new List<UUID>();
presenceBackReferences.Add(agentID);
m_presence_BackReferences[friendID] = presenceBackReferences;
}
}
/// <summary>
/// Removes a backreference to free up some memory
/// </summary>
/// <param name="agentID"></param>
/// <param name="friendID"></param>
public void removeBackReference(UUID agentID, UUID friendID)
{
if (m_presence_BackReferences.Contains(friendID))
{
List<UUID> presenseBackReferences = (List<UUID>)m_presence_BackReferences[friendID];
if (presenseBackReferences.Contains(agentID))
{
presenseBackReferences.Remove(agentID);
}
// If there are no more backreferences for this agent,
// remove it to free up memory.
if (presenseBackReferences.Count == 0)
{
m_presence_BackReferences.Remove(agentID);
}
// send an update about friend's presence to user.
enqueuePresenceUpdate(friendpresence, userpresence);
}
}
@ -256,90 +173,42 @@ namespace OpenSim.Grid.MessagingServer
private void ProcessLogOff(UUID AgentID)
{
m_log.Info("[LOGOFF]: Processing Logoff");
UserPresenceData AgentData = null;
List<UUID> AgentsNeedingNotification = new List<UUID>();
UserPresenceData friendd = null;
UserPresenceData userPresence = null;
lock (m_presences)
{
if (m_presences.Contains(AgentID))
{
AgentData = (UserPresenceData)m_presences[AgentID];
}
m_presences.TryGetValue(AgentID, out userPresence);
}
if (AgentData != null)
if (userPresence != null) // found the user
{
AgentsNeedingNotification = AgentData.subscriptionData;
AgentData.OnlineYN = false;
//lock (m_presence_BackReferences)
//{
//if (m_presence_BackReferences.Contains(AgentID))
//{
//AgentsNeedingNotification = (List<UUID>)m_presence_BackReferences[AgentID];
//}
//}
List<UUID> AgentsNeedingNotification = userPresence.subscriptionData;
userPresence.OnlineYN = false;
for (int i = 0; i < AgentsNeedingNotification.Count; i++)
{
// TODO: Do Region Notifications
UserPresenceData friendPresence = null;
lock (m_presences)
{
if (m_presences.Contains(AgentsNeedingNotification[i]))
{
friendd = (UserPresenceData)m_presences[AgentsNeedingNotification[i]];
}
m_presences.TryGetValue(AgentsNeedingNotification[i], out friendPresence);
}
// This might need to be enumerated and checked before we try to remove it.
if (friendd != null)
if (friendPresence != null)
{
lock (friendd)
lock (friendPresence)
{
friendd.subscriptionData.Remove(AgentID);
// no updates for this user anymore
friendPresence.subscriptionData.Remove(AgentID);
List<FriendListItem> fl = friendd.friendData;
for (int j = 0; j < fl.Count; j++)
// set user's entry in the friend's list to offline (if it exists)
if (friendPresence.friendData.ContainsKey(AgentID))
{
if (fl[j].Friend == AgentID)
{
fl[j].onlinestatus = false;
friendPresence.friendData[AgentID].onlinestatus = false;
}
}
friendd.friendData = fl;
m_presences[AgentsNeedingNotification[i]] = friendd;
}
UserAgentData p2Handle = m_userManager.GetUserAgentData(friendd.agentData.AgentID);
if (p2Handle != null)
{
friendd.regionData.regionHandle = p2Handle.Handle;
PresenceInformer friendlistupdater = new PresenceInformer();
friendlistupdater.presence1 = AgentData;
friendlistupdater.presence2 = friendd;
//friendlistupdater.gridserverurl = m_cfg.GridServerURL;
//friendlistupdater.gridserversendkey = m_cfg.GridSendKey;
//friendlistupdater.gridserverrecvkey = m_cfg.GridRecvKey;
friendlistupdater.OnGetRegionData += GetRegionInfo;
friendlistupdater.OnDone += PresenceUpdateDone;
WaitCallback cb3 = new WaitCallback(friendlistupdater.go);
ThreadPool.QueueUserWorkItem(cb3);
}
else
{
// skip, agent can't be found
}
//SendRegionPresenceUpdate(AgentData, friendd);
//removeBackReference(AgentID, AgentsNeedingNotification[i]);
enqueuePresenceUpdate(userPresence, friendPresence);
}
}
}
@ -347,7 +216,7 @@ namespace OpenSim.Grid.MessagingServer
#endregion
public void PresenceUpdateDone(PresenceInformer obj)
private void PresenceUpdateDone(PresenceInformer obj)
{
obj.OnGetRegionData -= GetRegionInfo;
obj.OnDone -= PresenceUpdateDone;
@ -356,12 +225,13 @@ namespace OpenSim.Grid.MessagingServer
#region UserServer Comms
/// <summary>
/// Returns a list of FriendsListItems that describe the friends and permissions in the friend relationship for UUID friendslistowner
/// Returns a list of FriendsListItems that describe the friends and permissions in the friend
/// relationship for UUID friendslistowner. For faster lookup, we index by friend's UUID.
/// </summary>
/// <param name="friendlistowner">The agent that we're retreiving the friends Data.</param>
public List<FriendListItem> GetUserFriendList(UUID friendlistowner)
/// <param name="friendlistowner">The agent that we're retreiving the friends Data for.</param>
private Dictionary<UUID, FriendListItem> GetUserFriendList(UUID friendlistowner)
{
List<FriendListItem> buddylist = new List<FriendListItem>();
Dictionary<UUID, FriendListItem> buddies = new Dictionary<UUID,FriendListItem>();
try
{
@ -376,7 +246,7 @@ namespace OpenSim.Grid.MessagingServer
if (respData.Contains("avcount"))
{
buddylist = ConvertXMLRPCDataToFriendListItemList(respData);
buddies = ConvertXMLRPCDataToFriendListItemList(respData);
}
}
@ -386,7 +256,7 @@ namespace OpenSim.Grid.MessagingServer
e.Message);
// Return Empty list (no friends)
}
return buddylist;
return buddies;
}
/// <summary>
@ -394,9 +264,9 @@ namespace OpenSim.Grid.MessagingServer
/// </summary>
/// <param name="data">XMLRPC response data Hashtable</param>
/// <returns></returns>
public List<FriendListItem> ConvertXMLRPCDataToFriendListItemList(Hashtable data)
public Dictionary<UUID, FriendListItem> ConvertXMLRPCDataToFriendListItemList(Hashtable data)
{
List<FriendListItem> buddylist = new List<FriendListItem>();
Dictionary<UUID, FriendListItem> buddies = new Dictionary<UUID,FriendListItem>();
int buddycount = Convert.ToInt32((string)data["avcount"]);
for (int i = 0; i < buddycount; i++)
@ -408,10 +278,10 @@ namespace OpenSim.Grid.MessagingServer
buddylistitem.FriendListOwnerPerms = (uint)Convert.ToInt32((string)data["ownerPerms" + i.ToString()]);
buddylistitem.FriendPerms = (uint)Convert.ToInt32((string)data["friendPerms" + i.ToString()]);
buddylist.Add(buddylistitem);
buddies.Add(buddylistitem.Friend, buddylistitem);
}
return buddylist;
return buddies;
}
/// <summary>
@ -423,20 +293,8 @@ namespace OpenSim.Grid.MessagingServer
/// <returns></returns>
public XmlRpcResponse UserLoggedOn(XmlRpcRequest request)
{
m_log.Info("[LOGON]: User logged on, building indexes for user");
Hashtable requestData = (Hashtable)request.Params[0];
//requestData["sendkey"] = serv.sendkey;
//requestData["agentid"] = agentID.ToString();
//requestData["sessionid"] = sessionID.ToString();
//requestData["regionid"] = RegionID.ToString();
//requestData["regionhandle"] = regionhandle.ToString();
//requestData["positionx"] = positionX.ToString();
//requestData["positiony"] = positionY.ToString();
//requestData["positionz"] = positionZ.ToString();
//requestData["firstname"] = firstname;
//requestData["lastname"] = lastname;
AgentCircuitData agentData = new AgentCircuitData();
agentData.SessionID = new UUID((string)requestData["sessionid"]);
agentData.SecureSessionID = new UUID((string)requestData["secure_session_id"]);
@ -461,12 +319,13 @@ namespace OpenSim.Grid.MessagingServer
ulong regionHandle = Convert.ToUInt64((string)requestData["regionhandle"]);
m_log.InfoFormat("[LOGON]: User {0} {1} logged into region {2} as {3} agent, building indexes for user",
agentData.firstname, agentData.lastname, regionHandle, agentData.child ? "child" : "root");
UserPresenceData up = new UserPresenceData();
up.agentData = agentData;
List<FriendListItem> flData = GetUserFriendList(agentData.AgentID);
up.friendData = flData;
RegionProfileData riData = GetRegionInfo(regionHandle);
up.regionData = riData;
up.friendData = GetUserFriendList(agentData.AgentID);
up.regionData = GetRegionInfo(regionHandle);
up.OnlineYN = true;
up.lookupUserRegionYN = false;
ProcessFriendListSubscriptions(up);
@ -486,7 +345,6 @@ namespace OpenSim.Grid.MessagingServer
Hashtable requestData = (Hashtable)request.Params[0];
UUID AgentID = new UUID((string)requestData["agentid"]);
ProcessLogOff(AgentID);
return new XmlRpcResponse();
@ -494,6 +352,49 @@ namespace OpenSim.Grid.MessagingServer
#endregion
public XmlRpcResponse GetPresenceInfoBulk(XmlRpcRequest request)
{
Hashtable paramHash = (Hashtable)request.Params[0];
Hashtable result = new Hashtable();
// TODO check access (recv_key/send_key)
IList list = (IList)paramHash["uuids"];
// convert into List<UUID>
List<UUID> uuids = new List<UUID>();
for (int i = 0; i < list.Count; ++i)
{
UUID uuid;
if (UUID.TryParse((string)list[i], out uuid))
{
uuids.Add(uuid);
}
}
try {
Dictionary<UUID, FriendRegionInfo> infos = m_userManager.GetFriendRegionInfos(uuids);
m_log.DebugFormat("[FRIEND]: Got {0} region entries back.", infos.Count);
int count = 0;
foreach (KeyValuePair<UUID, FriendRegionInfo> pair in infos)
{
result["uuid_" + count] = pair.Key.ToString();
result["isOnline_" + count] = pair.Value.isOnline;
result["regionHandle_" + count] = pair.Value.regionHandle.ToString(); // XML-RPC doesn't know ulongs
++count;
}
result["count"] = count;
XmlRpcResponse response = new XmlRpcResponse();
response.Value = result;
return response;
}
catch(Exception e) {
m_log.Error("Got exception:", e);
throw e;
}
}
#region regioninfo gathering
/// <summary>
@ -506,38 +407,22 @@ namespace OpenSim.Grid.MessagingServer
public RegionProfileData GetRegionInfo(ulong regionhandle)
{
RegionProfileData regionInfo = null;
bool lookup = false;
lock (m_regionInfoCache)
{
if (m_regionInfoCache.Contains(regionhandle))
{
regionInfo = (RegionProfileData)m_regionInfoCache[regionhandle];
}
else
{
// Don't lock the cache while we're looking up the region!
lookup = true;
}
m_regionInfoCache.TryGetValue(regionhandle, out regionInfo);
}
if (lookup)
if (regionInfo == null) // not found in cache
{
regionInfo = RequestRegionInfo(regionhandle);
if (regionInfo != null)
if (regionInfo != null) // lookup was successful
{
lock (m_regionInfoCache)
{
if (m_regionInfoCache.Contains(regionhandle))
{
m_regionInfoCache[regionhandle] = regionInfo;
}
else
{
m_regionInfoCache.Add(regionhandle, regionInfo);
}
}
}
}
@ -558,21 +443,25 @@ namespace OpenSim.Grid.MessagingServer
}
/// <summary>
/// Get RegionProfileData from the GridServer
/// We'll Cache this information and use it for presence updates
/// Get RegionProfileData from the GridServer.
/// We'll cache this information in GetRegionInfo and use it for presence updates
/// </summary>
/// <param name="regionHandle"></param>
/// <returns></returns>
public RegionProfileData RequestRegionInfo(ulong regionHandle)
{ RegionProfileData regionProfile = null;
{
RegionProfileData regionProfile = null;
try
{
Hashtable requestData = new Hashtable();
requestData["region_handle"] = regionHandle.ToString();
requestData["authkey"] = m_cfg.GridSendKey;
ArrayList SendParams = new ArrayList();
SendParams.Add(requestData);
XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
XmlRpcResponse GridResp = GridReq.Send(m_cfg.GridServerURL, 3000);
Hashtable responseData = (Hashtable)GridResp.Value;
@ -586,9 +475,6 @@ namespace OpenSim.Grid.MessagingServer
uint regX = Convert.ToUInt32((string)responseData["region_locx"]);
uint regY = Convert.ToUInt32((string)responseData["region_locy"]);
string internalIpStr = (string)responseData["sim_ip"];
// uint port = Convert.ToUInt32(responseData["sim_port"]);
// string externalUri = (string)responseData["sim_uri"];
// string neighbourExternalUri = externalUri;
regionProfile = new RegionProfileData();
regionProfile.httpPort = (uint)Convert.ToInt32((string)responseData["http_port"]);
@ -600,20 +486,12 @@ namespace OpenSim.Grid.MessagingServer
regionProfile.remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]);
regionProfile.UUID = new UUID((string)responseData["region_UUID"]);
regionProfile.regionName = (string)responseData["region_name"];
lock (m_regionInfoCache)
{
if (!m_regionInfoCache.Contains(regionHandle))
{
m_regionInfoCache.Add(regionHandle, regionProfile);
}
}
}
catch (WebException)
{
m_log.Error("[GRID]: " +
"Region lookup failed for: " + regionHandle.ToString() +
" - Is the GridServer down?");
return null;
}
return regionProfile;
@ -641,29 +519,20 @@ namespace OpenSim.Grid.MessagingServer
SendParams.Add(UserParams);
// Send Request
XmlRpcRequest UserReq;
XmlRpcResponse UserResp;
try
{
UserReq = new XmlRpcRequest("register_messageserver", SendParams);
UserResp = UserReq.Send(m_cfg.UserServerURL, 16000);
} catch (Exception ex)
{
m_log.Error("Unable to connect to grid. Grid server not running?");
throw(ex);
}
Hashtable GridRespData = (Hashtable)UserResp.Value;
// Hashtable griddatahash = GridRespData;
XmlRpcRequest UserReq = new XmlRpcRequest("register_messageserver", SendParams);
XmlRpcResponse UserResp = UserReq.Send(m_cfg.UserServerURL, 16000);
// Process Response
if (GridRespData.ContainsKey("responsestring"))
{
return true;
Hashtable GridRespData = (Hashtable)UserResp.Value;
// if we got a response, we were successful
return GridRespData.ContainsKey("responsestring");
}
else
catch (Exception ex)
{
return false;
m_log.Error("Unable to connect to grid. User server not running?");
throw(ex);
}
}
@ -689,30 +558,20 @@ namespace OpenSim.Grid.MessagingServer
SendParams.Add(UserParams);
// Send Request
XmlRpcRequest UserReq;
XmlRpcResponse UserResp;
try
{
UserReq = new XmlRpcRequest("deregister_messageserver", SendParams);
UserResp = UserReq.Send(m_cfg.UserServerURL, 16000);
XmlRpcRequest UserReq = new XmlRpcRequest("deregister_messageserver", SendParams);
XmlRpcResponse UserResp = UserReq.Send(m_cfg.UserServerURL, 16000);
// Process Response
Hashtable UserRespData = (Hashtable)UserResp.Value;
// if we got a response, we were successful
return UserRespData.ContainsKey("responsestring");
}
catch (Exception ex)
{
m_log.Error("Unable to connect to grid. Grid server not running?");
m_log.Error("Unable to connect to grid. User server not running?");
throw (ex);
}
Hashtable UserRespData = (Hashtable)UserResp.Value;
// Hashtable userdatahash = UserRespData;
// Process Response
if (UserRespData.ContainsKey("responsestring"))
{
return true;
}
else
{
return false;
}
}
#endregion

View File

@ -38,7 +38,7 @@ namespace OpenSim.Grid.MessagingServer
public AgentCircuitData agentData = new AgentCircuitData();
public RegionProfileData regionData = new RegionProfileData();
public string httpURI = String.Empty;
public List<FriendListItem> friendData = new List<FriendListItem> ();
public Dictionary<UUID, FriendListItem> friendData = new Dictionary<UUID,FriendListItem>();
public List<UUID> subscriptionData = new List<UUID>();
public bool OnlineYN = true;
public bool lookupUserRegionYN = true;

View File

@ -364,7 +364,8 @@ namespace OpenSim
m_commsManager
= new CommunicationsLocal(
m_networkServersInfo, m_httpServer, m_assetCache, userService, userService,
inventoryService, backendService, backendService, libraryRootFolder, m_dumpAssetsToFile);
inventoryService, backendService, backendService, userService,
libraryRootFolder, m_dumpAssetsToFile);
// set up XMLRPC handler for client's initial login request message
m_httpServer.AddXmlRPCHandler("login_to_simulator", loginService.XmlRpcLoginMethod);

View File

@ -4130,6 +4130,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
break;
case PacketType.DeclineFriendship:
DeclineFriendshipPacket dfriendpack = (DeclineFriendshipPacket)Pack;
if (OnDenyFriendRequest != null)
{
OnDenyFriendRequest(this,
dfriendpack.AgentData.AgentID,
dfriendpack.TransactionBlock.TransactionID,
null);
}
break;
case PacketType.TerminateFriendship:
TerminateFriendshipPacket tfriendpack = (TerminateFriendshipPacket)Pack;
UUID listOwnerAgentID = tfriendpack.AgentData.AgentID;
@ -7648,6 +7660,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
OutPacket(p, ThrottleOutPacketType.Task);
}
public void SendTerminateFriend(UUID exFriendID)
{
TerminateFriendshipPacket p = (TerminateFriendshipPacket)PacketPool.Instance.GetPacket(PacketType.TerminateFriendship);
p.AgentData.AgentID = AgentId;
p.AgentData.SessionID = SessionId;
p.ExBlock.OtherID = exFriendID;
OutPacket(p, ThrottleOutPacketType.Task);
}
public void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data)
{
int i;

View File

@ -42,7 +42,8 @@ namespace OpenSim.Region.Communications.Local
IUserServiceAdmin userServiceAdmin,
LocalInventoryService inventoryService,
IInterRegionCommunications interRegionService,
IGridServices gridService, LibraryRootFolder libraryRootFolder, bool dumpAssetsToFile)
IGridServices gridService, IMessagingService messageService,
LibraryRootFolder libraryRootFolder, bool dumpAssetsToFile)
: base(serversInfo, httpServer, assetCache, dumpAssetsToFile, libraryRootFolder)
{
AddInventoryService(inventoryService);
@ -53,6 +54,7 @@ namespace OpenSim.Region.Communications.Local
m_avatarService = (IAvatarService)userService;
m_gridService = gridService;
m_interRegion = interRegionService;
m_messageService = messageService;
}
}
}

View File

@ -529,5 +529,21 @@ namespace OpenSim.Region.Communications.Local
return regions;
}
public List<UUID> InformFriendsInOtherRegion(UUID agentId, ulong destRegionHandle, List<UUID> friends, bool online)
{
// if we get to here, something is wrong: We are in standalone mode, but have users that are not on our server?
m_log.WarnFormat("[INTERREGION STANDALONE] Did find {0} users on a region not on our server: {1} ???",
friends.Count, destRegionHandle);
return new List<UUID>();
}
public bool TriggerTerminateFriend (ulong regionHandle, UUID agentID, UUID exFriendID)
{
// if we get to here, something is wrong: We are in standalone mode, but have users that are not on our server?
m_log.WarnFormat("[INTERREGION STANDALONE] Did find user {0} on a region not on our server: {1} ???",
agentID, regionHandle);
return true;
}
}
}

View File

@ -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;
}

View File

@ -1785,5 +1785,83 @@ namespace OpenSim.Region.Communications.OGS1
return null;
}
}
public List<UUID> InformFriendsInOtherRegion(UUID agentId, ulong destRegionHandle, List<UUID> friends, bool online)
{
List<UUID> tpdAway = new List<UUID>();
// 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;
}
}
}
}

View File

@ -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<UUID, FriendRegionInfo> GetFriendRegionInfos (List<UUID> uuids)
{
Dictionary<UUID, FriendRegionInfo> result = new Dictionary<UUID, FriendRegionInfo>();
// 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

View File

@ -137,8 +137,14 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
// IM dialogs need to be pre-processed and have their sessionID filled by the server
// so the sim can match the transaction on the return packet.
// Don't send a Friend Dialog IM with a UUID.Zero session.
if (!dialogHandledElsewhere)
// Don't process IMs that are handled elsewhere (e.g. friend dialog
// IMs) with a non-UUID.Zero agent session, as those have been send
// by a client (either directly or from another region via
// inter-region communication) and will be processed in another
// module (e.g. the friends-module).
// IMs with fromAgentSession == UUID.Zero come from the server, and
// have to be passed to the matching viewer
if (!dialogHandledElsewhere || fromAgentSession == UUID.Zero)
{
// Try root avatar only first
foreach (Scene scene in m_scenes)

View File

@ -963,5 +963,9 @@ namespace OpenSim.Region.Environment.Modules.World.NPC
public void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data)
{
}
public void SendTerminateFriend(UUID exFriendID)
{
}
}
}

View File

@ -3200,6 +3200,20 @@ namespace OpenSim.Region.Environment.Scenes
return CommsManager.GetUserFriendList(avatarID);
}
public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos(List<UUID> uuids)
{
return CommsManager.GetFriendRegionInfos(uuids);
}
public List<UUID> InformFriendsInOtherRegion(UUID agentId, ulong destRegionHandle, List<UUID> 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);
}
#endregion

View File

@ -962,5 +962,9 @@ namespace OpenSim.Region.Examples.SimpleModule
public void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data)
{
}
public void SendTerminateFriend(UUID exFriendID)
{
}
}
}

View File

@ -4,6 +4,7 @@
<Import assembly="OpenSim.Grid.GridServer.exe"/>
<Import assembly="OpenSim.Grid.AssetServer.exe"/>
<Import assembly="OpenSim.Grid.InventoryServer.exe"/>
<Import assembly="OpenSim.Grid.MessagingServer.exe"/>
<Import assembly="OpenSim.Data.dll"/>
<Import assembly="OpenSim.Framework.dll"/>
</Runtime>

View File

@ -203,6 +203,9 @@ asset_server_url = "http://127.0.0.1:8003"
inventory_server_url = "http://127.0.0.1:8004"
; The MessagingServer is a companion of the UserServer. It uses
; user_send_key and user_recv_key, too
messaging_server_url = "http://127.0.0.1:8006"
[Chat]
whisper_distance = 10