Merge branch 'master' into careminster-presence-refactor

This commit is contained in:
Melanie
2010-05-08 13:31:36 +01:00
52 changed files with 1760 additions and 730 deletions

View File

@@ -526,11 +526,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
{
m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Request to teleport {0} {1} home", client.FirstName, client.LastName);
OpenSim.Services.Interfaces.PresenceInfo pinfo = m_aScene.PresenceService.GetAgent(client.SessionId);
//OpenSim.Services.Interfaces.PresenceInfo pinfo = m_aScene.PresenceService.GetAgent(client.SessionId);
GridUserInfo uinfo = m_aScene.GridUserService.GetGridUserInfo(client.AgentId.ToString());
if (pinfo != null)
if (uinfo != null)
{
GridRegion regionInfo = m_aScene.GridService.GetRegionByUUID(UUID.Zero, pinfo.HomeRegionID);
GridRegion regionInfo = m_aScene.GridService.GetRegionByUUID(UUID.Zero, uinfo.HomeRegionID);
if (regionInfo == null)
{
// can't find the Home region: Tell viewer and abort
@@ -539,7 +540,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
}
// a little eekie that this goes back to Scene and with a forced cast, will fix that at some point...
((Scene)(client.Scene)).RequestTeleportLocation(
client, regionInfo.RegionHandle, pinfo.HomePosition, pinfo.HomeLookAt,
client, regionInfo.RegionHandle, uinfo.HomePosition, uinfo.HomeLookAt,
(uint)(Constants.TeleportFlags.SetLastToTarget | Constants.TeleportFlags.ViaHome));
}
}

View File

@@ -154,7 +154,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
bool success = connector.LoginAgentToGrid(agentCircuit, reg, finalDestination, out reason);
if (success)
// Log them out of this grid
m_aScene.PresenceService.LogoutAgent(agentCircuit.SessionID, sp.AbsolutePosition, sp.Lookat);
m_aScene.PresenceService.LogoutAgent(agentCircuit.SessionID);
return success;
}
@@ -238,6 +238,13 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
{
if (obj.IsLoggingOut)
{
object sp = null;
if (obj.Scene.TryGetScenePresence(obj.AgentId, out sp))
{
if (((ScenePresence)sp).IsChildAgent)
return;
}
AgentCircuitData aCircuit = ((Scene)(obj.Scene)).AuthenticateHandler.GetAgentCircuitData(obj.CircuitCode);
if (aCircuit.ServiceURLs.ContainsKey("HomeURI"))

View File

@@ -59,9 +59,11 @@
<RegionModule id="RemoteUserAccountServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts.RemoteUserAccountServicesConnector" />
<RegionModule id="LocalGridUserServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser.LocalGridUserServicesConnector" />
<RegionModule id="RemoteGridUserServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser.RemoteGridUserServicesConnector" />
<RegionModule id="LocalSimulationConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation.LocalSimulationConnectorModule" />
<RegionModule id="RemoteSimulationConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation.RemoteSimulationConnectorModule" />
<!-- Service connectors IN modules -->
<RegionModule id="AssetServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Asset.AssetServiceInConnectorModule" />
<RegionModule id="InventoryServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Inventory.InventoryServiceInConnectorModule" />

View File

@@ -0,0 +1,116 @@
/*
* 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 OpenSimulator 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;
using System.Collections.Generic;
using System.Reflection;
using OpenSim.Framework;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
using OpenMetaverse;
using log4net;
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser
{
public class ActivityDetector
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private IGridUserService m_GridUserService;
private Scene m_aScene;
public ActivityDetector(IGridUserService guservice)
{
m_GridUserService = guservice;
m_log.DebugFormat("[ACTIVITY DETECTOR]: starting ");
}
public void AddRegion(Scene scene)
{
// For now the only events we listen to are these
// But we could trigger the position update more often
scene.EventManager.OnMakeRootAgent += OnMakeRootAgent;
scene.EventManager.OnNewClient += OnNewClient;
scene.EventManager.OnAvatarEnteringNewParcel += OnEnteringNewParcel;
if (m_aScene == null)
m_aScene = scene;
}
public void RemoveRegion(Scene scene)
{
scene.EventManager.OnMakeRootAgent -= OnMakeRootAgent;
scene.EventManager.OnNewClient -= OnNewClient;
}
public void OnMakeRootAgent(ScenePresence sp)
{
m_log.DebugFormat("[ACTIVITY DETECTOR]: Detected root presence {0} in {1}", sp.UUID, sp.Scene.RegionInfo.RegionName);
m_GridUserService.SetLastPosition(sp.UUID.ToString(), sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat);
}
public void OnNewClient(IClientAPI client)
{
client.OnConnectionClosed += OnConnectionClose;
}
public void OnConnectionClose(IClientAPI client)
{
if (client.IsLoggingOut)
{
object sp = null;
Vector3 position = new Vector3(128, 128, 0);
Vector3 lookat = new Vector3(0, 1, 0);
if (client.Scene.TryGetScenePresence(client.AgentId, out sp))
{
if (sp is ScenePresence)
{
if (((ScenePresence)sp).IsChildAgent)
return;
position = ((ScenePresence)sp).AbsolutePosition;
lookat = ((ScenePresence)sp).Lookat;
}
}
m_log.DebugFormat("[ACTIVITY DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName);
m_GridUserService.LoggedOut(client.AgentId.ToString(), client.Scene.RegionInfo.RegionID, position, lookat);
}
}
void OnEnteringNewParcel(ScenePresence sp, int localLandID, UUID regionID)
{
// TODO: grab the parcel ID from ILandModule
// and send that along
m_GridUserService.SetLastPosition(sp.UUID.ToString(), sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat);
}
}
}

View File

@@ -41,13 +41,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser
{
public class LocalGridUserServicesConnector : ISharedRegionModule, IGridUserService
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static readonly ILog m_log =
LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType);
private IGridUserService m_service;
private IGridUserService m_GridUserService;
private ActivityDetector m_ActivityDetector;
private bool m_Enabled = false;
public Type ReplaceableInterface
#region ISharedRegionModule
public Type ReplaceableInterface
{
get { return null; }
}
@@ -68,7 +74,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser
IConfig userConfig = source.Configs["GridUserService"];
if (userConfig == null)
{
m_log.Error("[LOCAL GRID USER SERVICE CONNECTOR]: GridUserService missing from ini files");
m_log.Error("[LOCAL GRID USER SERVICE CONNECTOR]: GridUserService missing from OpenSim.ini");
return;
}
@@ -81,15 +87,20 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser
}
Object[] args = new Object[] { source };
m_service = ServerUtils.LoadPlugin<IGridUserService>(serviceDll, args);
m_GridUserService = ServerUtils.LoadPlugin<IGridUserService>(serviceDll, args);
if (m_service == null)
if (m_GridUserService == null)
{
m_log.Error("[LOCAL GRID USER SERVICE CONNECTOR]: Can't load GridUser service");
m_log.ErrorFormat(
"[LOCAL GRID USER SERVICE CONNECTOR]: Cannot load user account service specified as {0}", serviceDll);
return;
}
m_ActivityDetector = new ActivityDetector(this);
m_Enabled = true;
m_log.Info("[LOCAL GRID USER SERVICE CONNECTOR]: Local GridUser connector enabled");
m_log.Info("[LOCAL GRID USER SERVICE CONNECTOR]: Local grid user connector enabled");
}
}
}
@@ -111,29 +122,57 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser
if (!m_Enabled)
return;
scene.RegisterModuleInterface<IGridUserService>(m_service);
scene.RegisterModuleInterface<IGridUserService>(m_GridUserService);
m_ActivityDetector.AddRegion(scene);
}
public void RemoveRegion(Scene scene)
{
if (!m_Enabled)
return;
scene.UnregisterModuleInterface<IGridUserService>(this);
m_ActivityDetector.RemoveRegion(scene);
}
public void RegionLoaded(Scene scene)
{
if (!m_Enabled)
return;
m_log.InfoFormat("[LOCAL GRID USER SERVICE CONNECTOR]: Enabled local grid user for region {0}", scene.RegionInfo.RegionName);
}
#endregion
#region IGridUserService
public GridUserInfo LoggedIn(string userID)
{
return m_GridUserService.LoggedIn(userID);
}
public bool LoggedOut(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
{
return m_GridUserService.LoggedOut(userID, regionID, lastPosition, lastLookAt);
}
public bool SetHome(string userID, UUID homeID, Vector3 homePosition, Vector3 homeLookAt)
{
return m_GridUserService.SetHome(userID, homeID, homePosition, homeLookAt);
}
public bool SetLastPosition(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
{
return m_GridUserService.SetLastPosition(userID, regionID, lastPosition, lastLookAt);
}
public GridUserInfo GetGridUserInfo(string userID)
{
return m_service.GetGridUserInfo(userID);
}
public bool StoreGridUserInfo(GridUserInfo info)
{
return m_service.StoreGridUserInfo(info);
return m_GridUserService.GetGridUserInfo(userID);
}
#endregion
}
}
}

View File

@@ -0,0 +1,153 @@
/*
* 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 OpenSimulator 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;
using System.Collections.Generic;
using System.Reflection;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Server.Base;
using OpenSim.Services.Interfaces;
using OpenSim.Services.Connectors;
using OpenMetaverse;
using log4net;
using Nini.Config;
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser
{
public class RemoteGridUserServicesConnector : ISharedRegionModule, IGridUserService
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
#region ISharedRegionModule
private bool m_Enabled = false;
private ActivityDetector m_ActivityDetector;
private IGridUserService m_RemoteConnector;
public Type ReplaceableInterface
{
get { return null; }
}
public string Name
{
get { return "RemoteGridUserServicesConnector"; }
}
public void Initialise(IConfigSource source)
{
IConfig moduleConfig = source.Configs["Modules"];
if (moduleConfig != null)
{
string name = moduleConfig.GetString("GridUserServices", "");
if (name == Name)
{
m_RemoteConnector = new GridUserServicesConnector(source);
m_Enabled = true;
m_ActivityDetector = new ActivityDetector(this);
m_log.Info("[REMOTE GRID USER CONNECTOR]: Remote grid user enabled");
}
}
}
public void PostInitialise()
{
}
public void Close()
{
}
public void AddRegion(Scene scene)
{
if (!m_Enabled)
return;
scene.RegisterModuleInterface<IGridUserService>(this);
m_ActivityDetector.AddRegion(scene);
m_log.InfoFormat("[REMOTE GRID USER CONNECTOR]: Enabled remote grid user for region {0}", scene.RegionInfo.RegionName);
}
public void RemoveRegion(Scene scene)
{
if (!m_Enabled)
return;
m_ActivityDetector.RemoveRegion(scene);
}
public void RegionLoaded(Scene scene)
{
if (!m_Enabled)
return;
}
#endregion
#region IGridUserService
public GridUserInfo LoggedIn(string userID)
{
m_log.Warn("[REMOTE GRID USER CONNECTOR]: LoggedIn not implemented at the simulators");
return null;
}
public bool LoggedOut(string userID, UUID region, Vector3 position, Vector3 lookat)
{
return m_RemoteConnector.LoggedOut(userID, region, position, lookat);
}
public bool SetHome(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
{
return m_RemoteConnector.SetHome(userID, regionID, position, lookAt);
}
public bool SetLastPosition(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
{
return m_RemoteConnector.SetLastPosition(userID, regionID, position, lookAt);
}
public GridUserInfo GetGridUserInfo(string userID)
{
return m_RemoteConnector.GetGridUserInfo(userID);
}
#endregion
}
}

View File

@@ -167,9 +167,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
return false;
}
public bool LogoutAgent(UUID sessionID, Vector3 position, Vector3 lookat)
public bool LogoutAgent(UUID sessionID)
{
return m_PresenceService.LogoutAgent(sessionID, position, lookat);
return m_PresenceService.LogoutAgent(sessionID);
}
@@ -178,9 +178,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
return m_PresenceService.LogoutRegionAgents(regionID);
}
public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt)
public bool ReportAgent(UUID sessionID, UUID regionID)
{
return m_PresenceService.ReportAgent(sessionID, regionID, position, lookAt);
return m_PresenceService.ReportAgent(sessionID, regionID);
}
public PresenceInfo GetAgent(UUID sessionID)
@@ -193,11 +193,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
return m_PresenceService.GetAgents(userIDs);
}
public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
{
return m_PresenceService.SetHomeLocation(userID, regionID, position, lookAt);
}
#endregion
}

View File

@@ -72,7 +72,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
public void OnMakeRootAgent(ScenePresence sp)
{
m_log.DebugFormat("[PRESENCE DETECTOR]: Detected root presence {0} in {1}", sp.UUID, sp.Scene.RegionInfo.RegionName);
m_PresenceService.ReportAgent(sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat);
m_PresenceService.ReportAgent(sp.ControllingClient.SessionId, sp.Scene.RegionInfo.RegionID);
}
public void OnNewClient(IClientAPI client)
@@ -85,19 +85,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
if (client.IsLoggingOut)
{
object sp = null;
Vector3 position = new Vector3(128, 128, 0);
Vector3 lookat = new Vector3(0, 1, 0);
if (client.Scene.TryGetScenePresence(client.AgentId, out sp))
{
if (sp is ScenePresence)
{
position = ((ScenePresence)sp).AbsolutePosition;
lookat = ((ScenePresence)sp).Lookat;
if (((ScenePresence)sp).IsChildAgent)
return;
}
}
m_PresenceService.LogoutAgent(client.SessionId, position, lookat);
m_log.DebugFormat("[PRESENCE DETECTOR]: Detected client logout {0} in {1}", client.AgentId, client.Scene.RegionInfo.RegionName);
m_PresenceService.LogoutAgent(client.SessionId);
}
}

View File

@@ -127,9 +127,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
return false;
}
public bool LogoutAgent(UUID sessionID, Vector3 position, Vector3 lookat)
public bool LogoutAgent(UUID sessionID)
{
return m_RemoteConnector.LogoutAgent(sessionID, position, lookat);
return m_RemoteConnector.LogoutAgent(sessionID);
}
@@ -138,9 +138,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
return m_RemoteConnector.LogoutRegionAgents(regionID);
}
public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt)
public bool ReportAgent(UUID sessionID, UUID regionID)
{
return m_RemoteConnector.ReportAgent(sessionID, regionID, position, lookAt);
return m_RemoteConnector.ReportAgent(sessionID, regionID);
}
public PresenceInfo GetAgent(UUID sessionID)
@@ -153,11 +153,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence
return m_RemoteConnector.GetAgents(userIDs);
}
public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
{
return m_RemoteConnector.SetHomeLocation(userID, regionID, position, lookAt);
}
#endregion
}

View File

@@ -90,27 +90,25 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence.Tests
PresenceInfo result = m_LocalConnector.GetAgent(session1);
Assert.IsNotNull(result, "Retrieved GetAgent is null");
Assert.That(result.UserID, Is.EqualTo(user1), "Retrieved userID does not match");
Assert.IsTrue(result.Online, "Agent just logged in but is offline");
UUID region1 = UUID.Random();
bool r = m_LocalConnector.ReportAgent(session1, region1, Vector3.Zero, Vector3.Zero);
bool r = m_LocalConnector.ReportAgent(session1, region1);
Assert.IsTrue(r, "First ReportAgent returned false");
result = m_LocalConnector.GetAgent(session1);
Assert.That(result.RegionID, Is.EqualTo(region1), "Agent is not in the right region (region1)");
UUID region2 = UUID.Random();
r = m_LocalConnector.ReportAgent(session1, region2, Vector3.Zero, Vector3.Zero);
r = m_LocalConnector.ReportAgent(session1, region2);
Assert.IsTrue(r, "Second ReportAgent returned false");
result = m_LocalConnector.GetAgent(session1);
Assert.That(result.RegionID, Is.EqualTo(region2), "Agent is not in the right region (region2)");
r = m_LocalConnector.LogoutAgent(session1, Vector3.Zero, Vector3.UnitY);
r = m_LocalConnector.LogoutAgent(session1);
Assert.IsTrue(r, "LogoutAgent returned false");
result = m_LocalConnector.GetAgent(session1);
Assert.IsNotNull(result, "Agent session disappeared from storage after logout");
Assert.IsFalse(result.Online, "Agent is reported to be Online after logout");
Assert.IsNull(result, "Agent session is still stored after logout");
r = m_LocalConnector.ReportAgent(session1, region1, Vector3.Zero, Vector3.Zero);
r = m_LocalConnector.ReportAgent(session1, region1);
Assert.IsFalse(r, "ReportAgent of non-logged in user returned true");
}
}