From f11a97f12d328af8bb39b92fec5cb5780983b66a Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 7 Jan 2010 15:53:55 -0800 Subject: * Finished SimulationServiceConnector * Started rerouting calls to UserService. * Compiles. May run. --- OpenSim/Framework/ChildAgentDataUpdate.cs | 10 +- .../Avatar/InstantMessage/MessageTransferModule.cs | 60 +++++--- .../Inventory/Archiver/InventoryArchiverModule.cs | 2 +- .../Avatar/Profiles/AvatarProfilesModule.cs | 43 +++--- .../RemoteAuthorizationServiceConnector.cs | 6 +- .../Presence/RemotePresenceServiceConnector.cs | 2 +- .../Simulation/LocalSimulationConnector.cs | 19 ++- .../Simulation/RemoteSimulationConnector.cs | 11 +- .../Hypergrid/HGSceneCommunicationService.cs | 12 +- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 10 +- OpenSim/Region/Framework/Scenes/Scene.cs | 86 +++++++---- .../Framework/Scenes/SceneCommunicationService.cs | 34 +++-- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 19 ++- .../Framework/Scenes/Tests/ScenePresenceTests.cs | 2 +- .../Server/Handlers/Simulation/AgentHandlers.cs | 2 +- .../Simulation/SimulationServiceConnector.cs | 169 ++++++++++++++++++++- OpenSim/Services/Interfaces/ISimulationService.cs | 2 +- 17 files changed, 360 insertions(+), 129 deletions(-) diff --git a/OpenSim/Framework/ChildAgentDataUpdate.cs b/OpenSim/Framework/ChildAgentDataUpdate.cs index 825ab81..b6b7996 100644 --- a/OpenSim/Framework/ChildAgentDataUpdate.cs +++ b/OpenSim/Framework/ChildAgentDataUpdate.cs @@ -274,7 +274,7 @@ namespace OpenSim.Framework get { return m_id; } set { m_id = value; } } - public ulong RegionHandle; + public UUID RegionID; public uint CircuitCode; public UUID SessionID; @@ -321,7 +321,7 @@ namespace OpenSim.Framework OSDMap args = new OSDMap(); args["message_type"] = OSD.FromString("AgentData"); - args["region_handle"] = OSD.FromString(RegionHandle.ToString()); + args["region_id"] = OSD.FromString(RegionID.ToString()); args["circuit_code"] = OSD.FromString(CircuitCode.ToString()); args["agent_uuid"] = OSD.FromUUID(AgentID); args["session_uuid"] = OSD.FromUUID(SessionID); @@ -414,8 +414,8 @@ namespace OpenSim.Framework /// public virtual void Unpack(OSDMap args) { - if (args.ContainsKey("region_handle")) - UInt64.TryParse(args["region_handle"].AsString(), out RegionHandle); + if (args.ContainsKey("region_id")) + UUID.TryParse(args["region_id"].AsString(), out RegionID); if (args["circuit_code"] != null) UInt32.TryParse((string)args["circuit_code"].AsString(), out CircuitCode); @@ -572,7 +572,7 @@ namespace OpenSim.Framework { System.Console.WriteLine("------------ AgentData ------------"); System.Console.WriteLine("UUID: " + AgentID); - System.Console.WriteLine("Region: " + RegionHandle); + System.Console.WriteLine("Region: " + RegionID); System.Console.WriteLine("Position: " + Position); } } diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs index 2d4b421..c0d3f31 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs @@ -37,6 +37,8 @@ using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using GridRegion = OpenSim.Services.Interfaces.GridRegion; +using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; +using OpenSim.Services.Interfaces; namespace OpenSim.Region.CoreModules.Avatar.InstantMessage { @@ -46,10 +48,21 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage private bool m_Enabled = false; protected List m_Scenes = new List(); - protected Dictionary m_UserRegionMap = new Dictionary(); + protected Dictionary m_UserRegionMap = new Dictionary(); public event UndeliveredMessage OnUndeliveredMessage; + private IPresenceService m_PresenceService; + protected IPresenceService PresenceService + { + get + { + if (m_PresenceService == null) + m_PresenceService = m_Scenes[0].RequestModuleInterface(); + return m_PresenceService; + } + } + public virtual void Initialise(IConfigSource config) { IConfig cnf = config.Configs["Messaging"]; @@ -416,7 +429,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage /// /// delegate for sending a grid instant message asynchronously /// - public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result, ulong prevRegionHandle); + public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID); protected virtual void GridInstantMessageCompleted(IAsyncResult iar) { @@ -430,7 +443,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage { GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsync; - d.BeginInvoke(im, result, 0, GridInstantMessageCompleted, d); + d.BeginInvoke(im, result, UUID.Zero, GridInstantMessageCompleted, d); } /// @@ -445,11 +458,11 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage /// Pass in 0 the first time this method is called. It will be called recursively with the last /// regionhandle tried /// - protected virtual void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, ulong prevRegionHandle) + protected virtual void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID) { UUID toAgentID = new UUID(im.toAgentID); - UserAgentData upd = null; + PresenceInfo upd = null; bool lookupAgent = false; @@ -457,13 +470,13 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage { if (m_UserRegionMap.ContainsKey(toAgentID)) { - upd = new UserAgentData(); - upd.AgentOnline = true; - upd.Handle = m_UserRegionMap[toAgentID]; + upd = new PresenceInfo(); + upd.Online = true; + upd.RegionID = m_UserRegionMap[toAgentID]; // We need to compare the current regionhandle with the previous region handle // or the recursive loop will never end because it will never try to lookup the agent again - if (prevRegionHandle == upd.Handle) + if (prevRegionID == upd.RegionID) { lookupAgent = true; } @@ -479,14 +492,23 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage if (lookupAgent) { // Non-cached user agent lookup. - upd = m_Scenes[0].CommsManager.UserService.GetAgentByUUID(toAgentID); + PresenceInfo[] presences = PresenceService.GetAgents(new string[] { toAgentID.ToString() }); + if (presences != null) + { + foreach (PresenceInfo p in presences) + if (p.Online) + { + upd = presences[0]; + break; + } + } if (upd != null) { // check if we've tried this before.. // This is one way to end the recursive loop // - if (upd.Handle == prevRegionHandle) + if (upd.RegionID == prevRegionID) { m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message"); HandleUndeliveredMessage(im, result); @@ -503,12 +525,10 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage if (upd != null) { - if (upd.AgentOnline) + if (upd.Online) { - uint x = 0, y = 0; - Utils.LongToUInts(upd.Handle, out x, out y); - GridRegion reginfo = m_Scenes[0].GridService.GetRegionByPosition(m_Scenes[0].RegionInfo.ScopeID, - (int)x, (int)y); + GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, + upd.RegionID); if (reginfo != null) { Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im); @@ -524,11 +544,11 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage { if (m_UserRegionMap.ContainsKey(toAgentID)) { - m_UserRegionMap[toAgentID] = upd.Handle; + m_UserRegionMap[toAgentID] = upd.RegionID; } else { - m_UserRegionMap.Add(toAgentID, upd.Handle); + m_UserRegionMap.Add(toAgentID, upd.RegionID); } } result(true); @@ -543,12 +563,12 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage // This is recursive!!!!! SendGridInstantMessageViaXMLRPCAsync(im, result, - upd.Handle); + upd.RegionID); } } else { - m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find region {0}", upd.Handle); + m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find region {0}", upd.RegionID); HandleUndeliveredMessage(im, result); } } diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index ecd60bd..6da43a8 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -335,7 +335,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver try { - if (m_aScene.CommsManager.UserService.AuthenticateUserByPassword(userInfo.UserProfile.ID, pass)) + if (m_aScene.AuthenticationService.Authenticate(userInfo.UserProfile.ID, pass, 1) != string.Empty) { return userInfo; } diff --git a/OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs b/OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs index 8cf58c6..718ee2f 100644 --- a/OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Profiles/AvatarProfilesModule.cs @@ -110,7 +110,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Profiles public void RequestAvatarProperty(IClientAPI remoteClient, UUID avatarID) { // FIXME: finish adding fields such as url, masking, etc. - UserProfileData profile = m_scene.CommsManager.UserService.GetUserProfile(avatarID); + UserProfileData profile = null; // m_scene.CommsManager.UserService.GetUserProfile(avatarID); if (null != profile) { Byte[] charterMember; @@ -143,26 +143,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Profiles public void UpdateAvatarProperties(IClientAPI remoteClient, UserProfileData newProfile) { - UserProfileData Profile = m_scene.CommsManager.UserService.GetUserProfile(newProfile.ID); - - // if it's the profile of the user requesting the update, then we change only a few things. - if (remoteClient.AgentId.CompareTo(Profile.ID) == 0) - { - Profile.Image = newProfile.Image; - Profile.FirstLifeImage = newProfile.FirstLifeImage; - Profile.AboutText = newProfile.AboutText; - Profile.FirstLifeAboutText = newProfile.FirstLifeAboutText; - Profile.ProfileUrl = newProfile.ProfileUrl; - } - else - { - return; - } - - if (m_scene.CommsManager.UserService.UpdateUserProfile(Profile)) - { - RequestAvatarProperty(remoteClient, newProfile.ID); - } + return; + //UserProfileData Profile = m_scene.CommsManager.UserService.GetUserProfile(newProfile.ID); + + //// if it's the profile of the user requesting the update, then we change only a few things. + //if (remoteClient.AgentId.CompareTo(Profile.ID) == 0) + //{ + // Profile.Image = newProfile.Image; + // Profile.FirstLifeImage = newProfile.FirstLifeImage; + // Profile.AboutText = newProfile.AboutText; + // Profile.FirstLifeAboutText = newProfile.FirstLifeAboutText; + // Profile.ProfileUrl = newProfile.ProfileUrl; + //} + //else + //{ + // return; + //} + + //if (m_scene.CommsManager.UserService.UpdateUserProfile(Profile)) + //{ + // RequestAvatarProperty(remoteClient, newProfile.ID); + //} } } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs index 68499f3..01a2615 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs @@ -139,9 +139,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization if (scene != null) { - UserProfileData profile = scene.CommsManager.UserService.GetUserProfile(new UUID(userID)); - isAuthorized = IsAuthorizedForRegion(userID, profile.FirstName, profile.SurName, - profile.Email, scene.RegionInfo.RegionName, regionID, out message); + UserAccount account = scene.UserAccountService.GetUserAccount(UUID.Zero, userID); + isAuthorized = IsAuthorizedForRegion(userID, account.FirstName, account.LastName, + account.Email, scene.RegionInfo.RegionName, regionID, out message); } else { diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs index e8e140a..6c69570 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs @@ -59,7 +59,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence public string Name { - get { return "RemotePresenceServiceConnector"; } + get { return "RemotePresenceServicesConnector"; } } public void Initialise(IConfigSource source) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs index 074bfb5..c6c6af0 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs @@ -172,12 +172,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation { if (s.RegionInfo.RegionHandle == destination.RegionHandle) { -// m_log.DebugFormat("[LOCAL COMMS]: Found region {0} to send SendCreateChildAgent", regionHandle); + m_log.DebugFormat("[LOCAL COMMS]: Found region {0} to send SendCreateChildAgent", destination.RegionName); return s.NewUserConnection(aCircuit, teleportFlags, out reason); } } -// m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for SendCreateChildAgent", regionHandle); + m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for SendCreateChildAgent", destination.RegionName); reason = "Did not find region " + destination.RegionName; return false; } @@ -241,14 +241,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation return false; } - public bool ReleaseAgent(GridRegion destination, UUID id, string uri) + public bool ReleaseAgent(UUID origin, UUID id, string uri) { - if (destination == null) - return false; - foreach (Scene s in m_sceneList) { - if (s.RegionInfo.RegionHandle == destination.RegionHandle) + if (s.RegionInfo.RegionID == origin) { //m_log.Debug("[LOCAL COMMS]: Found region to SendReleaseAgent"); return s.IncomingReleaseAgent(id); @@ -334,6 +331,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation return false; } + public bool IsLocalRegion(UUID id) + { + foreach (Scene s in m_sceneList) + if (s.RegionInfo.RegionID == id) + return true; + return false; + } + #endregion } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs index c9cc368..f485cd1 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs @@ -245,18 +245,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation } - public bool ReleaseAgent(GridRegion destination, UUID id, string uri) + public bool ReleaseAgent(UUID origin, UUID id, string uri) { - if (destination == null) - return false; - // Try local first - if (m_localBackend.ReleaseAgent(destination, id, uri)) + if (m_localBackend.ReleaseAgent(origin, id, uri)) return true; // else do the remote thing - if (!m_localBackend.IsLocalRegion(destination.RegionHandle)) - return m_remoteConnector.ReleaseAgent(destination, id, uri); + if (!m_localBackend.IsLocalRegion(origin)) + return m_remoteConnector.ReleaseAgent(origin, id, uri); return false; } diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs index 416826c..f64a7a0 100644 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs @@ -202,8 +202,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid string reason = String.Empty; - //if (!m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agentCircuit)) - if (!m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, agentCircuit, teleportFlags, out reason)) + if (!m_scene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason)) { avatar.ControllingClient.SendTeleportFailed(String.Format("Destination is not accepting teleports: {0}", reason)); @@ -282,9 +281,9 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid avatar.CopyTo(agent); agent.Position = position; agent.CallbackURI = "http://" + m_regionInfo.ExternalHostName + ":" + m_regionInfo.HttpPort + - "/agent/" + avatar.UUID.ToString() + "/" + avatar.Scene.RegionInfo.RegionHandle.ToString() + "/release/"; + "/agent/" + avatar.UUID.ToString() + "/" + avatar.Scene.RegionInfo.RegionID.ToString() + "/release/"; - m_interregionCommsOut.SendChildAgentUpdate(reg.RegionHandle, agent); + m_scene.SimulationService.UpdateAgent(reg, agent); m_log.DebugFormat( "[CAPS]: Sending new CAPS seed url {0} to client {1}", agentCircuit.CapsPath, avatar.UUID); @@ -322,8 +321,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid avatar.Scene.InformClientOfNeighbours(avatar); // Finally, kill the agent we just created at the destination. - m_interregionCommsOut.SendCloseAgent(reg.RegionHandle, avatar.UUID); - + m_scene.SimulationService.CloseAgent(reg, avatar.UUID); return; } @@ -336,7 +334,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid avatar.MakeChildAgent(); // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it - avatar.CrossAttachmentsIntoNewRegion(reg.RegionHandle, true); + avatar.CrossAttachmentsIntoNewRegion(reg, true); // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index a14c853..1c5c247 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1163,15 +1163,21 @@ namespace OpenSim.Region.Framework.Scenes private void SendInventoryUpdate(IClientAPI client, InventoryFolderBase folder, bool fetchFolders, bool fetchItems) { + if (folder == null) + return; + m_log.DebugFormat("[AGENT INVENTORY]: Send Inventory Folder {0} Update to {1} {2}", folder.Name, client.FirstName, client.LastName); InventoryCollection contents = InventoryService.GetFolderContent(client.AgentId, folder.ID); InventoryFolderBase containingFolder = new InventoryFolderBase(); containingFolder.ID = folder.ID; containingFolder.Owner = client.AgentId; containingFolder = InventoryService.GetFolder(containingFolder); - int version = containingFolder.Version; + if (containingFolder != null) + { + int version = containingFolder.Version; - client.SendInventoryFolderDetails(client.AgentId, folder.ID, contents.Items, contents.Folders, version, fetchFolders, fetchItems); + client.SendInventoryFolderDetails(client.AgentId, folder.ID, contents.Items, contents.Folders, version, fetchFolders, fetchItems); + } } /// diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 20c0622..d8874b2 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -253,6 +253,49 @@ namespace OpenSim.Region.Framework.Scenes } } + protected ISimulationService m_simulationService; + public ISimulationService SimulationService + { + get + { + if (m_simulationService == null) + m_simulationService = RequestModuleInterface(); + return m_simulationService; + } + } + + protected IAuthenticationService m_AuthenticationService; + public IAuthenticationService AuthenticationService + { + get + { + if (m_AuthenticationService == null) + m_AuthenticationService = RequestModuleInterface(); + return m_AuthenticationService; + } + } + + protected IPresenceService m_PresenceService; + public IPresenceService PresenceService + { + get + { + if (m_PresenceService == null) + m_PresenceService = RequestModuleInterface(); + return m_PresenceService; + } + } + protected IUserAccountService m_UserAccountService; + public IUserAccountService UserAccountService + { + get + { + if (m_UserAccountService == null) + m_UserAccountService = RequestModuleInterface(); + return m_UserAccountService; + } + } + protected IXMLRPC m_xmlrpcModule; protected IWorldComm m_worldCommModule; protected IAvatarFactory m_AvatarFactory; @@ -262,8 +305,6 @@ namespace OpenSim.Region.Framework.Scenes } protected IConfigSource m_config; protected IRegionSerialiserModule m_serialiser; - protected IInterregionCommsOut m_interregionCommsOut; - protected IInterregionCommsIn m_interregionCommsIn; protected IDialogModule m_dialogModule; protected ITeleportModule m_teleportModule; @@ -1136,8 +1177,6 @@ namespace OpenSim.Region.Framework.Scenes XferManager = RequestModuleInterface(); m_AvatarFactory = RequestModuleInterface(); m_serialiser = RequestModuleInterface(); - m_interregionCommsOut = RequestModuleInterface(); - m_interregionCommsIn = RequestModuleInterface(); m_dialogModule = RequestModuleInterface(); m_capsModule = RequestModuleInterface(); m_teleportModule = RequestModuleInterface(); @@ -2155,7 +2194,10 @@ namespace OpenSim.Region.Framework.Scenes grp.OffsetForNewRegion(pos); // If we fail to cross the border, then reset the position of the scene object on that border. - if (!CrossPrimGroupIntoNewRegion(newRegionHandle, grp, silent)) + uint x = 0, y = 0; + Utils.LongToUInts(newRegionHandle, out x, out y); + GridRegion destination = GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); + if (destination != null && !CrossPrimGroupIntoNewRegion(destination, grp, silent)) { grp.OffsetForNewRegion(oldGroupPosition); grp.ScheduleGroupForFullUpdate(); @@ -2351,7 +2393,7 @@ namespace OpenSim.Region.Framework.Scenes /// true if the crossing itself was successful, false on failure /// FIMXE: we still return true if the crossing object was not successfully deleted from the originating region /// - public bool CrossPrimGroupIntoNewRegion(ulong newRegionHandle, SceneObjectGroup grp, bool silent) + public bool CrossPrimGroupIntoNewRegion(GridRegion destination, SceneObjectGroup grp, bool silent) { //m_log.Debug(" >>> CrossPrimGroupIntoNewRegion <<<"); @@ -2359,7 +2401,7 @@ namespace OpenSim.Region.Framework.Scenes grp.RootPart.UpdateFlag = 0; //int primcrossingXMLmethod = 0; - if (newRegionHandle != 0) + if (destination != null) { //string objectState = grp.GetStateSnapshot(); @@ -2372,9 +2414,11 @@ namespace OpenSim.Region.Framework.Scenes // newRegionHandle, grp.UUID, objectState, 100); //} - // And the new channel... - if (m_interregionCommsOut != null) - successYN = m_interregionCommsOut.SendCreateObject(newRegionHandle, grp, true); + //// And the new channel... + //if (m_interregionCommsOut != null) + // successYN = m_interregionCommsOut.SendCreateObject(newRegionHandle, grp, true); + if (m_simulationService != null) + successYN = m_simulationService.CreateObject(destination, grp, true); if (successYN) { @@ -2405,7 +2449,7 @@ namespace OpenSim.Region.Framework.Scenes } else { - m_log.Error("[INTERREGION]: region handle was unexpectedly 0 in Scene.CrossPrimGroupIntoNewRegion()"); + m_log.Error("[INTERREGION]: destination was unexpectedly null in Scene.CrossPrimGroupIntoNewRegion()"); } return successYN; @@ -2598,10 +2642,9 @@ namespace OpenSim.Region.Framework.Scenes m_log.Debug(logMsg); */ - CommsManager.UserProfileCacheService.AddNewUser(client.AgentId); + //CommsManager.UserProfileCacheService.AddNewUser(client.AgentId); ScenePresence sp = CreateAndAddScenePresence(client); - // HERE!!! Do the initial attachments right here // first agent upon login is a root agent by design. // All other AddNewClient calls find aCircuit.child to be true @@ -2614,6 +2657,7 @@ namespace OpenSim.Region.Framework.Scenes m_LastLogin = Util.EnvironmentTickCount(); EventManager.TriggerOnNewClient(client); + } @@ -3289,14 +3333,6 @@ namespace OpenSim.Region.Framework.Scenes m_sceneGridService.KiPrimitive += SendKillObject; m_sceneGridService.OnGetLandData += GetLandData; - if (m_interregionCommsIn != null) - { - m_log.Debug("[SCENE]: Registering with InterregionCommsIn"); - m_interregionCommsIn.OnChildAgentUpdate += IncomingChildAgentDataUpdate; - } - else - m_log.Debug("[SCENE]: Unable to register with InterregionCommsIn"); - } /// @@ -3314,9 +3350,6 @@ namespace OpenSim.Region.Framework.Scenes m_sceneGridService.OnCloseAgentConnection -= IncomingCloseAgent; m_sceneGridService.OnGetLandData -= GetLandData; - if (m_interregionCommsIn != null) - m_interregionCommsIn.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; - // this does nothing; should be removed m_sceneGridService.Close(); @@ -3758,9 +3791,10 @@ namespace OpenSim.Region.Framework.Scenes return m_sceneGridService.ReleaseAgent(id); } - public void SendReleaseAgent(ulong regionHandle, UUID id, string uri) + public void SendReleaseAgent(UUID origin, UUID id, string uri) { - m_interregionCommsOut.SendReleaseAgent(regionHandle, id, uri); + //m_interregionCommsOut.SendReleaseAgent(regionHandle, id, uri); + m_simulationService.ReleaseAgent(origin, id, uri); } /// diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index f49d072..f612d17 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs @@ -57,7 +57,6 @@ namespace OpenSim.Region.Framework.Scenes private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); protected CommunicationsManager m_commsProvider; - protected IInterregionCommsOut m_interregionCommsOut; protected RegionInfo m_regionInfo; protected Scene m_scene; @@ -135,7 +134,6 @@ namespace OpenSim.Region.Framework.Scenes { m_scene = s; m_regionInfo = s.RegionInfo; - m_interregionCommsOut = m_scene.RequestModuleInterface(); } /// @@ -255,6 +253,7 @@ namespace OpenSim.Region.Framework.Scenes { InformClientOfNeighbourDelegate icon = (InformClientOfNeighbourDelegate) iar.AsyncState; icon.EndInvoke(iar); + m_log.WarnFormat(" --> InformClientOfNeighbourCompleted"); } /// @@ -285,8 +284,8 @@ namespace OpenSim.Region.Framework.Scenes string reason = String.Empty; - - bool regionAccepted = m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a, 0, out reason); + + bool regionAccepted = m_scene.SimulationService.CreateAgent(reg, a, 0, out reason); // m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a, 0, out reason); if (regionAccepted && newAgent) { @@ -460,6 +459,7 @@ namespace OpenSim.Region.Framework.Scenes int count = 0; foreach (GridRegion neighbour in neighbours) { + m_log.WarnFormat("--> Going to send child agent to {0}", neighbour.RegionName); // Don't do it if there's already an agent in that region if (newRegions.Contains(neighbour.RegionHandle)) newAgent = true; @@ -600,7 +600,10 @@ namespace OpenSim.Region.Framework.Scenes try { //m_commsProvider.InterRegion.ChildAgentUpdate(regionHandle, cAgentData); - m_interregionCommsOut.SendChildAgentUpdate(regionHandle, cAgentData); + uint x = 0, y = 0; + Utils.LongToUInts(regionHandle, out x, out y); + GridRegion destination = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); + m_scene.SimulationService.UpdateAgent(destination, cAgentData); } catch { @@ -660,7 +663,10 @@ namespace OpenSim.Region.Framework.Scenes // let's do our best, but there's not much we can do if the neighbour doesn't accept. //m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, agentID); - m_interregionCommsOut.SendCloseAgent(regionHandle, agentID); + uint x = 0, y = 0; + Utils.LongToUInts(regionHandle, out x, out y); + GridRegion destination = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); + m_scene.SimulationService.CloseAgent(destination, agentID); } private void SendCloseChildAgentCompleted(IAsyncResult iar) @@ -810,7 +816,7 @@ namespace OpenSim.Region.Framework.Scenes // Let's create an agent there if one doesn't exist yet. //if (!m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agentCircuit)) - if (!m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, agentCircuit, teleportFlags, out reason)) + if (!m_scene.SimulationService.CreateAgent(reg, agentCircuit, teleportFlags, out reason)) { avatar.ControllingClient.SendTeleportFailed(String.Format("Destination is not accepting teleports: {0}", reason)); @@ -896,9 +902,9 @@ namespace OpenSim.Region.Framework.Scenes avatar.CopyTo(agent); agent.Position = position; agent.CallbackURI = "http://" + m_regionInfo.ExternalHostName + ":" + m_regionInfo.HttpPort + - "/agent/" + avatar.UUID.ToString() + "/" + avatar.Scene.RegionInfo.RegionHandle.ToString() + "/release/"; + "/agent/" + avatar.UUID.ToString() + "/" + avatar.Scene.RegionInfo.RegionID.ToString() + "/release/"; - m_interregionCommsOut.SendChildAgentUpdate(reg.RegionHandle, agent); + m_scene.SimulationService.UpdateAgent(reg, agent); m_log.DebugFormat( "[CAPS]: Sending new CAPS seed url {0} to client {1}", capsPath, avatar.UUID); @@ -929,7 +935,7 @@ namespace OpenSim.Region.Framework.Scenes avatar.Scene.InformClientOfNeighbours(avatar); // Finally, kill the agent we just created at the destination. - m_interregionCommsOut.SendCloseAgent(reg.RegionHandle, avatar.UUID); + m_scene.SimulationService.CloseAgent(reg, avatar.UUID); return; } @@ -943,7 +949,7 @@ namespace OpenSim.Region.Framework.Scenes avatar.MakeChildAgent(); // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it - avatar.CrossAttachmentsIntoNewRegion(reg.RegionHandle, true); + avatar.CrossAttachmentsIntoNewRegion(reg, true); // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone @@ -1338,9 +1344,9 @@ namespace OpenSim.Region.Framework.Scenes if (isFlying) cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY; cAgent.CallbackURI = "http://" + m_regionInfo.ExternalHostName + ":" + m_regionInfo.HttpPort + - "/agent/" + agent.UUID.ToString() + "/" + agent.Scene.RegionInfo.RegionHandle.ToString() + "/release/"; + "/agent/" + agent.UUID.ToString() + "/" + agent.Scene.RegionInfo.RegionID.ToString() + "/release/"; - m_interregionCommsOut.SendChildAgentUpdate(neighbourHandle, cAgent); + m_scene.SimulationService.UpdateAgent(neighbourRegion, cAgent); // Next, let's close the child agent connections that are too far away. agent.CloseChildAgents(neighbourx, neighboury); @@ -1391,7 +1397,7 @@ namespace OpenSim.Region.Framework.Scenes // now we have a child agent in this region. Request all interesting data about other (root) agents agent.SendInitialFullUpdateToAllClients(); - agent.CrossAttachmentsIntoNewRegion(neighbourHandle, true); + agent.CrossAttachmentsIntoNewRegion(neighbourRegion, true); // m_scene.SendKillObject(m_localId); diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 8545425..385a9cd 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -246,6 +246,8 @@ namespace OpenSim.Region.Framework.Scenes // For teleports and crossings callbacks string m_callbackURI; + UUID m_originRegionID; + ulong m_rootRegionHandle; /// @@ -890,7 +892,9 @@ namespace OpenSim.Region.Framework.Scenes presence.Animator.SendAnimPackToClient(ControllingClient); } + m_log.Warn("BEFORE ON MAKE ROOT"); m_scene.EventManager.TriggerOnMakeRootAgent(this); + m_log.Warn("AFTER ON MAKE ROOT"); } /// @@ -1094,7 +1098,7 @@ namespace OpenSim.Region.Framework.Scenes if ((m_callbackURI != null) && !m_callbackURI.Equals("")) { m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI); - Scene.SendReleaseAgent(m_rootRegionHandle, UUID, m_callbackURI); + Scene.SendReleaseAgent(m_originRegionID, UUID, m_callbackURI); m_callbackURI = null; } @@ -1102,7 +1106,6 @@ namespace OpenSim.Region.Framework.Scenes m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); SendInitialData(); - } /// @@ -2482,7 +2485,7 @@ namespace OpenSim.Region.Framework.Scenes SendInitialFullUpdateToAllClients(); SendAppearanceToAllOtherAgents(); - } + } /// /// Tell the client for this scene presence what items it should be wearing now @@ -2937,7 +2940,7 @@ namespace OpenSim.Region.Framework.Scenes public void CopyTo(AgentData cAgent) { cAgent.AgentID = UUID; - cAgent.RegionHandle = m_rootRegionHandle; + cAgent.RegionID = Scene.RegionInfo.RegionID; cAgent.Position = AbsolutePosition; cAgent.Velocity = m_velocity; @@ -3036,7 +3039,7 @@ namespace OpenSim.Region.Framework.Scenes public void CopyFrom(AgentData cAgent) { - m_rootRegionHandle = cAgent.RegionHandle; + m_originRegionID = cAgent.RegionID; m_callbackURI = cAgent.CallbackURI; @@ -3406,7 +3409,7 @@ namespace OpenSim.Region.Framework.Scenes } } - public bool CrossAttachmentsIntoNewRegion(ulong regionHandle, bool silent) + public bool CrossAttachmentsIntoNewRegion(GridRegion destination, bool silent) { lock (m_attachments) { @@ -3427,8 +3430,8 @@ namespace OpenSim.Region.Framework.Scenes gobj.AbsolutePosition = gobj.RootPart.AttachedPos; gobj.RootPart.IsAttachment = false; //gobj.RootPart.LastOwnerID = gobj.GetFromAssetID(); - m_log.DebugFormat("[ATTACHMENT]: Sending attachment {0} to region {1}", gobj.UUID, regionHandle); - m_scene.CrossPrimGroupIntoNewRegion(regionHandle, gobj, silent); + m_log.DebugFormat("[ATTACHMENT]: Sending attachment {0} to region {1}", gobj.UUID, destination.RegionName); + m_scene.CrossPrimGroupIntoNewRegion(destination, gobj, silent); } } m_attachments.Clear(); diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs index f00dd66..51134a9 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs @@ -373,7 +373,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross"); - Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful"); + //Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful"); Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted"); Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects"); } diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs index ccb4c70..782034b 100644 --- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs +++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs @@ -313,7 +313,7 @@ namespace OpenSim.Server.Handlers.Simulation destination.RegionID = regionID; if (action.Equals("release")) - m_SimulationService.ReleaseAgent(destination, id, ""); + m_SimulationService.ReleaseAgent(regionID, id, ""); else m_SimulationService.CloseAgent(destination, id); diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs index dc532d0..76558aa 100644 --- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs +++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs @@ -385,14 +385,89 @@ namespace OpenSim.Services.Connectors.Simulation return false; } - public bool ReleaseAgent(GridRegion destination, UUID id, string uri) + public bool ReleaseAgent(UUID origin, UUID id, string uri) { - return false; + WebRequest request = WebRequest.Create(uri); + request.Method = "DELETE"; + request.Timeout = 10000; + + StreamReader sr = null; + try + { + WebResponse webResponse = request.GetResponse(); + if (webResponse == null) + { + m_log.Info("[REMOTE SIMULATION CONNECTOR]: Null reply on ReleaseAgent"); + } + + sr = new StreamReader(webResponse.GetResponseStream()); + //reply = sr.ReadToEnd().Trim(); + sr.ReadToEnd().Trim(); + sr.Close(); + //m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: ChilAgentUpdate reply was {0} ", reply); + + } + catch (WebException ex) + { + m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of ReleaseAgent {0}", ex.Message); + return false; + } + finally + { + if (sr != null) + sr.Close(); + } + + return true; } public bool CloseAgent(GridRegion destination, UUID id) { - return false; + string uri = string.Empty; + try + { + uri = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + "/agent/" + id + "/" + destination.RegionHandle.ToString() + "/"; + } + catch (Exception e) + { + m_log.Debug("[REMOTE SIMULATION CONNECTOR]: Unable to resolve external endpoint on agent close. Reason: " + e.Message); + return false; + } + + //Console.WriteLine(" >>> DoCloseAgentCall <<< " + uri); + + WebRequest request = WebRequest.Create(uri); + request.Method = "DELETE"; + request.Timeout = 10000; + + StreamReader sr = null; + try + { + WebResponse webResponse = request.GetResponse(); + if (webResponse == null) + { + m_log.Info("[REMOTE SIMULATION CONNECTOR]: Null reply on agent delete "); + } + + sr = new StreamReader(webResponse.GetResponseStream()); + //reply = sr.ReadToEnd().Trim(); + sr.ReadToEnd().Trim(); + sr.Close(); + //m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: ChilAgentUpdate reply was {0} ", reply); + + } + catch (WebException ex) + { + m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of agent delete {0}", ex.Message); + return false; + } + finally + { + if (sr != null) + sr.Close(); + } + + return true; } #endregion Agents @@ -401,11 +476,97 @@ namespace OpenSim.Services.Connectors.Simulation public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall) { - return false; + string uri + = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + "/object/" + sog.UUID + "/"; + //m_log.Debug(" >>> DoCreateChildAgentCall <<< " + uri); + + WebRequest ObjectCreateRequest = WebRequest.Create(uri); + ObjectCreateRequest.Method = "POST"; + ObjectCreateRequest.ContentType = "application/json"; + ObjectCreateRequest.Timeout = 10000; + + OSDMap args = new OSDMap(2); + args["sog"] = OSD.FromString(sog.ToXml2()); + args["extra"] = OSD.FromString(sog.ExtraToXmlString()); + string state = sog.GetStateSnapshot(); + if (state.Length > 0) + args["state"] = OSD.FromString(state); + // Add the input general arguments + args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString()); + args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString()); + args["destination_name"] = OSD.FromString(destination.RegionName); + args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString()); + + string strBuffer = ""; + byte[] buffer = new byte[1]; + try + { + strBuffer = OSDParser.SerializeJsonString(args); + Encoding str = Util.UTF8; + buffer = str.GetBytes(strBuffer); + + } + catch (Exception e) + { + m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR]: Exception thrown on serialization of CreateObject: {0}", e.Message); + // ignore. buffer will be empty, caller should check. + } + + Stream os = null; + try + { // send the Post + ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send + os = ObjectCreateRequest.GetRequestStream(); + os.Write(buffer, 0, strBuffer.Length); //Send it + m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Posted CreateObject request to remote sim {0}", uri); + } + catch (WebException ex) + { + m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Bad send on CreateObject {0}", ex.Message); + return false; + } + finally + { + if (os != null) + os.Close(); + } + + // Let's wait for the response + //m_log.Info("[REMOTE SIMULATION CONNECTOR]: Waiting for a reply after DoCreateChildAgentCall"); + + StreamReader sr = null; + try + { + WebResponse webResponse = ObjectCreateRequest.GetResponse(); + if (webResponse == null) + { + m_log.Info("[REMOTE SIMULATION CONNECTOR]: Null reply on CreateObject post"); + return false; + } + + sr = new StreamReader(webResponse.GetResponseStream()); + //reply = sr.ReadToEnd().Trim(); + sr.ReadToEnd().Trim(); + //m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: DoCreateChildAgentCall reply was {0} ", reply); + + } + catch (WebException ex) + { + m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of CreateObject {0}", ex.Message); + return false; + } + finally + { + if (sr != null) + sr.Close(); + } + + return true; } public bool CreateObject(GridRegion destination, UUID userID, UUID itemID) { + // TODO, not that urgent return false; } diff --git a/OpenSim/Services/Interfaces/ISimulationService.cs b/OpenSim/Services/Interfaces/ISimulationService.cs index 14f462c..ec24d90 100644 --- a/OpenSim/Services/Interfaces/ISimulationService.cs +++ b/OpenSim/Services/Interfaces/ISimulationService.cs @@ -67,7 +67,7 @@ namespace OpenSim.Services.Interfaces /// /// /// - bool ReleaseAgent(GridRegion destination, UUID id, string uri); + bool ReleaseAgent(UUID originRegion, UUID id, string uri); /// /// Close agent. -- cgit v1.1