From 0ce9be653d2194877cb972cbce261eecb0cd58a8 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 31 Dec 2009 14:59:26 -0800 Subject: * Added the Login server handlers that were lost in yesterday's commit grief * More beef to the LLLoginService * Better design for handling local simulation service --- OpenSim/Services/Interfaces/ILoginService.cs | 3 + OpenSim/Services/LLLoginService/LLLoginResponse.cs | 4 +- OpenSim/Services/LLLoginService/LLLoginService.cs | 66 ++++++++++++++++++---- 3 files changed, 59 insertions(+), 14 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Interfaces/ILoginService.cs b/OpenSim/Services/Interfaces/ILoginService.cs index 5397b10..0f82de5 100644 --- a/OpenSim/Services/Interfaces/ILoginService.cs +++ b/OpenSim/Services/Interfaces/ILoginService.cs @@ -29,11 +29,14 @@ using System; using System.Collections; using System.Collections.Generic; +using OpenMetaverse.StructuredData; + namespace OpenSim.Services.Interfaces { public abstract class LoginResponse { public abstract Hashtable ToHashtable(); + public abstract OSD ToOSDMap(); } public abstract class FailedLoginResponse : LoginResponse diff --git a/OpenSim/Services/LLLoginService/LLLoginResponse.cs b/OpenSim/Services/LLLoginService/LLLoginResponse.cs index e3935a8..fbce63f 100644 --- a/OpenSim/Services/LLLoginService/LLLoginResponse.cs +++ b/OpenSim/Services/LLLoginService/LLLoginResponse.cs @@ -92,7 +92,7 @@ namespace OpenSim.Services.LLLoginService return loginError; } - public OSD ToOSDMap() + public override OSD ToOSDMap() { OSDMap map = new OSDMap(); @@ -327,7 +327,7 @@ namespace OpenSim.Services.LLLoginService } } - public OSD ToLLSDResponse() + public override OSD ToOSDMap() { try { diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs index 4501da2..25a65b5 100644 --- a/OpenSim/Services/LLLoginService/LLLoginService.cs +++ b/OpenSim/Services/LLLoginService/LLLoginService.cs @@ -23,12 +23,12 @@ namespace OpenSim.Services.LLLoginService private IInventoryService m_InventoryService; private IGridService m_GridService; private IPresenceService m_PresenceService; + private ISimulationService m_LocalSimulationService; private string m_DefaultRegionName; - private string m_LocalSimulationDll; private string m_RemoteSimulationDll; - public LLLoginService(IConfigSource config) + public LLLoginService(IConfigSource config, ISimulationService simService) { IConfig serverConfig = config.Configs["LoginService"]; if (serverConfig == null) @@ -41,7 +41,6 @@ namespace OpenSim.Services.LLLoginService string presenceService = serverConfig.GetString("PresenceService", String.Empty); m_DefaultRegionName = serverConfig.GetString("DefaultRegion", String.Empty); - m_LocalSimulationDll = serverConfig.GetString("LocalSimulationService", String.Empty); m_RemoteSimulationDll = serverConfig.GetString("RemoteSimulationService", String.Empty); // These 3 are required; the other 2 aren't @@ -57,11 +56,18 @@ namespace OpenSim.Services.LLLoginService m_GridService = ServerUtils.LoadPlugin(gridService, args); if (presenceService != string.Empty) m_PresenceService = ServerUtils.LoadPlugin(presenceService, args); + m_LocalSimulationService = simService; } + public LLLoginService(IConfigSource config) : this(config, null) + { + } + public LoginResponse Login(string firstName, string lastName, string passwd, string startLocation) { + bool success = false; + // Get the account and check that it exists UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, firstName, lastName); if (account == null) @@ -82,31 +88,46 @@ namespace OpenSim.Services.LLLoginService UUID session = UUID.Random(); if (m_PresenceService != null) { - bool success = m_PresenceService.LoginAgent(account.PrincipalID.ToString(), session, secureSession); + success = m_PresenceService.LoginAgent(account.PrincipalID.ToString(), session, secureSession); if (!success) return LLFailedLoginResponse.GridProblem; } - // lots of things missing... need to do the simulation service + // Find the destination region/grid string where = string.Empty; Vector3 position = Vector3.Zero; Vector3 lookAt = Vector3.Zero; GridRegion destination = FindDestination(account, session, startLocation, out where, out position, out lookAt); if (destination == null) + { + m_PresenceService.LogoutAgent(session); return LLFailedLoginResponse.GridProblem; + } - ISimulationService sim = null; + // Instantiate/get the simulation interface and launch an agent at the destination + ISimulationService simConnector = null; + success = false; + string reason = string.Empty; Object[] args = new Object[] { destination }; // HG standalones have both a localSimulatonDll and a remoteSimulationDll // non-HG standalones have just a localSimulationDll // independent login servers have just a remoteSimulationDll - if (!startLocation.Contains("@") && (m_LocalSimulationDll != string.Empty)) - sim = ServerUtils.LoadPlugin(m_LocalSimulationDll, args); - else - sim = ServerUtils.LoadPlugin(m_RemoteSimulationDll, args); - + if (!startLocation.Contains("@") && (m_LocalSimulationService != null)) + simConnector = m_LocalSimulationService; + else if (m_RemoteSimulationDll != string.Empty) + simConnector = ServerUtils.LoadPlugin(m_RemoteSimulationDll, args); + if (simConnector != null) + success = LaunchAgent(simConnector, destination, account, session, out reason); + if (!success) + { + m_PresenceService.LogoutAgent(session); + return LLFailedLoginResponse.GridProblem; + } - return null; + // Finally, fill out the response and return it + LLLoginResponse response = new LLLoginResponse(); + //.... + return response; } private GridRegion FindDestination(UserAccount account, UUID sessionID, string startLocation, out string where, out Vector3 position, out Vector3 lookAt) @@ -228,5 +249,26 @@ namespace OpenSim.Services.LLLoginService } } + + private bool LaunchAgent(ISimulationService simConnector, GridRegion region, UserAccount account, UUID session, out string reason) + { + reason = string.Empty; + AgentCircuitData aCircuit = new AgentCircuitData(); + aCircuit.AgentID = account.PrincipalID; + //aCircuit.Appearance = optional + //aCircuit.BaseFolder = irrelevant + //aCircuit.CapsPath = required + aCircuit.child = false; + //aCircuit.circuitcode = required + aCircuit.firstname = account.FirstName; + //aCircuit.InventoryFolder = irrelevant + aCircuit.lastname = account.LastName; + //aCircuit.SecureSessionID = required + aCircuit.SessionID = session; + //aCircuit.startpos = required + + return simConnector.CreateAgent(region.RegionHandle, aCircuit, 0, out reason); + + } } } -- cgit v1.1