From 5c5966545d14de43500b95109e8ce81058ebe2c3 Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Sun, 28 Feb 2010 12:07:38 -0800
Subject: Initial Online friends notification seems to be working reliably now.
All this needs more testing, but everything is there.
---
.../Region/Framework/Interfaces/IFriendsModule.cs | 1 +
OpenSim/Region/Framework/Scenes/EventManager.cs | 27 +++++++++++++++++++++-
OpenSim/Region/Framework/Scenes/Scene.cs | 6 ++++-
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 ++++-
4 files changed, 37 insertions(+), 3 deletions(-)
(limited to 'OpenSim/Region/Framework')
diff --git a/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs b/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs
index 239a2ba..a0a1e3a 100644
--- a/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs
@@ -47,5 +47,6 @@ namespace OpenSim.Region.Framework.Interfaces
///
void OfferFriendship(UUID fromUserId, IClientAPI toUserClient, string offerMessage);
uint GetFriendPerms(UUID PrincipalID, UUID FriendID);
+ void SendFriendsOnlineIfNeeded(IClientAPI client);
}
}
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index 57e1c37..ac04462 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -66,13 +66,16 @@ namespace OpenSim.Region.Framework.Scenes
public event OnClientConnectCoreDelegate OnClientConnect;
public delegate void OnNewClientDelegate(IClientAPI client);
-
+
///
/// Deprecated in favour of OnClientConnect.
/// Will be marked Obsolete after IClientCore has 100% of IClientAPI interfaces.
///
public event OnNewClientDelegate OnNewClient;
+ public delegate void OnClientLoginDelegate(IClientAPI client);
+ public event OnClientLoginDelegate OnClientLogin;
+
public delegate void OnNewPresenceDelegate(ScenePresence presence);
public event OnNewPresenceDelegate OnNewPresence;
@@ -583,6 +586,28 @@ namespace OpenSim.Region.Framework.Scenes
}
}
+ public void TriggerOnClientLogin(IClientAPI client)
+ {
+ OnClientLoginDelegate handlerClientLogin = OnClientLogin;
+ if (handlerClientLogin != null)
+ {
+ foreach (OnClientLoginDelegate d in handlerClientLogin.GetInvocationList())
+ {
+ try
+ {
+ d(client);
+ }
+ catch (Exception e)
+ {
+ m_log.ErrorFormat(
+ "[EVENT MANAGER]: Delegate for TriggerOnClientLogin failed - continuing. {0} {1}",
+ e.Message, e.StackTrace);
+ }
+ }
+ }
+
+ }
+
public void TriggerOnNewPresence(ScenePresence presence)
{
OnNewPresenceDelegate handlerNewPresence = OnNewPresence;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index b9b16ad..d00c990 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2422,6 +2422,8 @@ namespace OpenSim.Region.Framework.Scenes
///
public override void AddNewClient(IClientAPI client)
{
+ bool vialogin = false;
+
m_clientManager.Add(client);
CheckHeartbeat();
@@ -2463,6 +2465,7 @@ namespace OpenSim.Region.Framework.Scenes
if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0)
{
m_log.DebugFormat("[Scene]: Incoming client {0} {1} in region {2} via Login", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName);
+ vialogin = true;
IUserAgentVerificationModule userVerification = RequestModuleInterface();
if (userVerification != null)
{
@@ -2512,7 +2515,8 @@ namespace OpenSim.Region.Framework.Scenes
m_LastLogin = Util.EnvironmentTickCount();
EventManager.TriggerOnNewClient(client);
-
+ if (vialogin)
+ EventManager.TriggerOnClientLogin(client);
}
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index af9afa6..f83a4d2 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -1114,7 +1114,7 @@ namespace OpenSim.Region.Framework.Scenes
/// This is called upon a very important packet sent from the client,
/// so it's client-controlled. Never call this method directly.
///
- public void CompleteMovement()
+ public void CompleteMovement(IClientAPI client)
{
//m_log.Debug("[SCENE PRESENCE]: CompleteMovement");
@@ -1159,6 +1159,10 @@ namespace OpenSim.Region.Framework.Scenes
m_agentTransfer.EnableChildAgents(this);
else
m_log.DebugFormat("[SCENE PRESENCE]: Unable to create child agents in neighbours, because AgentTransferModule is not active");
+
+ IFriendsModule friendsModule = m_scene.RequestModuleInterface();
+ if (friendsModule != null)
+ friendsModule.SendFriendsOnlineIfNeeded(ControllingClient);
}
}
--
cgit v1.1