* With Grid Comms up in the air.. I decided have the friends module update you when your friends come online if they're at least a child agent on the sim. offline status works the same also. So does Instant Message.

* This is until Grid Comms matures a bit more on this.
* This should also work in Standalone as it uses the IUserData interface.
0.6.0-stable
Teravus Ovares 2008-04-10 18:30:34 +00:00
parent b41abbd50e
commit 50c5e6af10
4 changed files with 166 additions and 1 deletions

View File

@ -516,7 +516,7 @@ namespace OpenSim.Region.Communications.OGS1
IList parameters = new ArrayList();
parameters.Add(param);
XmlRpcRequest req = new XmlRpcRequest("get_user_friend_list", parameters);
XmlRpcResponse resp = req.Send(m_parent.NetworkServersInfo.UserURL, 3000);
XmlRpcResponse resp = req.Send(m_parent.NetworkServersInfo.UserURL, 8000);
Hashtable respData = (Hashtable) resp.Value;
if (respData.Contains("avcount"))

View File

@ -27,6 +27,7 @@
using System;
using System.Collections.Generic;
using libsecondlife;
using libsecondlife.Packets;
using Nini.Config;
using Nwc.XmlRpc;
using OpenSim.Framework;
@ -45,6 +46,8 @@ namespace OpenSim.Region.Environment.Modules
Dictionary<LLUUID, LLUUID> m_pendingFriendRequests = new Dictionary<LLUUID, LLUUID>();
Dictionary<LLUUID, List<FriendListItem>> FriendLists = new Dictionary<LLUUID, List<FriendListItem>>();
public void Initialise(Scene scene, IConfigSource config)
{
lock (m_scene)
@ -78,11 +81,92 @@ namespace OpenSim.Region.Environment.Modules
// Generated by LoginService. The friends are retreived from the database by the UserManager
// Subscribe to instant messages
client.OnInstantMessage += OnInstantMessage;
client.OnApproveFriendRequest += OnApprovedFriendRequest;
client.OnDenyFriendRequest += OnDenyFriendRequest;
client.OnTerminateFriendship += OnTerminateFriendship;
List<FriendListItem> fl = new List<FriendListItem>();
lock (FriendLists)
{
if (FriendLists.ContainsKey(client.AgentId))
{
fl = FriendLists[client.AgentId];
}
else
{
fl = m_scene[0].GetFriendList(client.AgentId);
lock (FriendLists)
{
if (!FriendLists.ContainsKey(client.AgentId))
FriendLists.Add(client.AgentId, fl);
}
}
}
List<LLUUID> UpdateUsers = new List<LLUUID>();
foreach (FriendListItem f in fl)
{
if (m_rootAgents.ContainsKey(f.Friend))
{
if (f.onlinestatus == false)
{
UpdateUsers.Add(f.Friend);
f.onlinestatus = true;
}
}
}
foreach (LLUUID user in UpdateUsers)
{
ScenePresence av = GetPresenceFromAgentID(user);
if (av != null)
{
List<FriendListItem> usrfl = new List<FriendListItem>();
lock (FriendLists)
{
usrfl = FriendLists[user];
}
lock (usrfl)
{
foreach (FriendListItem fli in usrfl)
{
if (fli.Friend == client.AgentId)
{
fli.onlinestatus = true;
OnlineNotificationPacket onp = new OnlineNotificationPacket();
OnlineNotificationPacket.AgentBlockBlock[] onpb = new OnlineNotificationPacket.AgentBlockBlock[1];
OnlineNotificationPacket.AgentBlockBlock onpbl = new OnlineNotificationPacket.AgentBlockBlock();
onpbl.AgentID = client.AgentId;
onpb[0] = onpbl;
onp.AgentBlock = onpb;
av.ControllingClient.OutPacket(onp, ThrottleOutPacketType.Task);
}
}
}
}
}
if (UpdateUsers.Count > 0)
{
OnlineNotificationPacket onp = new OnlineNotificationPacket();
OnlineNotificationPacket.AgentBlockBlock[] onpb = new OnlineNotificationPacket.AgentBlockBlock[UpdateUsers.Count];
for (int i = 0; i < UpdateUsers.Count; i++)
{
OnlineNotificationPacket.AgentBlockBlock onpbl = new OnlineNotificationPacket.AgentBlockBlock();
onpbl.AgentID = UpdateUsers[i];
onpb[i] = onpbl;
}
onp.AgentBlock = onpb;
client.OutPacket(onp, ThrottleOutPacketType.Task);
}
}
private void ClientLoggedOut(LLUUID AgentId)
@ -95,6 +179,60 @@ namespace OpenSim.Region.Environment.Modules
m_log.Info("[FRIEND]: Removing " + AgentId + ". Agent logged out.");
}
}
List<FriendListItem> lfli = new List<FriendListItem>();
lock (FriendLists)
{
if (FriendLists.ContainsKey(AgentId))
{
lfli = FriendLists[AgentId];
}
}
List<LLUUID> updateUsers = new List<LLUUID>();
foreach (FriendListItem fli in lfli)
{
if (fli.onlinestatus = true)
{
updateUsers.Add(fli.Friend);
}
}
for (int i = 0; i < updateUsers.Count; i++)
{
List<FriendListItem> flfli = new List<FriendListItem>();
lock (FriendLists)
{
if (FriendLists.ContainsKey(updateUsers[i]))
flfli = FriendLists[updateUsers[i]];
}
for (int j = 0; j < flfli.Count; j++)
{
if (flfli[i].Friend == AgentId)
{
flfli[i].onlinestatus = false;
}
}
}
for (int i = 0; i < updateUsers.Count; i++)
{
ScenePresence av = GetPresenceFromAgentID(updateUsers[i]);
if (av != null)
{
OfflineNotificationPacket onp = new OfflineNotificationPacket();
OfflineNotificationPacket.AgentBlockBlock[] onpb = new OfflineNotificationPacket.AgentBlockBlock[1];
OfflineNotificationPacket.AgentBlockBlock onpbl = new OfflineNotificationPacket.AgentBlockBlock();
onpbl.AgentID = AgentId;
onpb[0] = onpbl;
onp.AgentBlock = onpb;
av.ControllingClient.OutPacket(onp, ThrottleOutPacketType.Task);
}
}
lock (FriendLists)
{
FriendLists.Remove(AgentId);
}
}
private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, LLUUID regionID)

View File

@ -82,6 +82,7 @@ namespace OpenSim.Region.Environment.Modules
// Don't send a Friend Dialog IM with a LLUUID.Zero session.
if (!(dialogHandledElsewhere && imSessionID == LLUUID.Zero))
{
// Try root avatar only first
foreach (Scene scene in m_scenes)
{
if (scene.Entities.ContainsKey(toAgentID) && scene.Entities[toAgentID] is ScenePresence)
@ -98,8 +99,27 @@ namespace OpenSim.Region.Environment.Modules
}
}
}
// try child avatar second
foreach (Scene scene in m_scenes)
{
if (scene.Entities.ContainsKey(toAgentID) && scene.Entities[toAgentID] is ScenePresence)
{
// Local message
ScenePresence user = (ScenePresence)scene.Entities[toAgentID];
user.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message,
toAgentID, imSessionID, fromAgentName, dialog,
timestamp);
// Message sent
return;
}
}
}
// Still here, try send via Grid
// TODO
}

View File

@ -2145,8 +2145,15 @@ namespace OpenSim.Region.Environment.Scenes
m_statsReporter.SetObjectCapacity(objects);
}
objectCapacity = objects;
}
public List<FriendListItem> GetFriendList(LLUUID avatarID)
{
return CommsManager.GetUserFriendList(avatarID);
}
#endregion
#region Other Methods