mirror of
https://github.com/opensim/opensim.git
synced 2026-08-13 05:05:43 +08:00
getting all our line endings consistant again
This commit is contained in:
@@ -24,35 +24,35 @@
|
||||
* (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.Text;
|
||||
|
||||
namespace OpenSim.Grid.ScriptServer
|
||||
{
|
||||
class OpenScript_Main
|
||||
{
|
||||
|
||||
public static ScriptServerMain SE;
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
// Application is starting
|
||||
SE = new ScriptServerMain();
|
||||
|
||||
System.AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
|
||||
}
|
||||
|
||||
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
||||
{
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("APPLICATION EXCEPTION DETECTED");
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("Application is terminating: " + e.IsTerminating.ToString());
|
||||
Console.WriteLine("Exception:");
|
||||
Console.WriteLine(e.ExceptionObject.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Grid.ScriptServer
|
||||
{
|
||||
class OpenScript_Main
|
||||
{
|
||||
|
||||
public static ScriptServerMain SE;
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
// Application is starting
|
||||
SE = new ScriptServerMain();
|
||||
|
||||
System.AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
|
||||
}
|
||||
|
||||
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
||||
{
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("APPLICATION EXCEPTION DETECTED");
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("Application is terminating: " + e.IsTerminating.ToString());
|
||||
Console.WriteLine("Exception:");
|
||||
Console.WriteLine(e.ExceptionObject.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,33 +1,33 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("OpenSim.Grid.ScriptServer")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("OpenSim.Grid.ScriptServer")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2007")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("b6861b87-5203-4040-b756-fd4774932f82")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("OpenSim.Grid.ScriptServer")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("OpenSim.Grid.ScriptServer")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2007")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("b6861b87-5203-4040-b756-fd4774932f82")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Grid.ScriptServer
|
||||
{
|
||||
// Maintains connection and communication to a region
|
||||
internal class RegionConnectionManager
|
||||
{
|
||||
|
||||
public RegionConnectionManager()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Grid.ScriptServer
|
||||
{
|
||||
// Maintains connection and communication to a region
|
||||
internal class RegionConnectionManager
|
||||
{
|
||||
|
||||
public RegionConnectionManager()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,76 +24,76 @@
|
||||
* (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.Text;
|
||||
using System.Threading;
|
||||
using OpenSim.Framework.Console;
|
||||
|
||||
namespace OpenSim.Grid.ScriptServer
|
||||
{
|
||||
// Waiting for incoming script requests from region
|
||||
internal class RegionCommManager
|
||||
{
|
||||
private Thread listenThread;
|
||||
|
||||
private List<RegionConnectionManager> Regions = new List<RegionConnectionManager>();
|
||||
|
||||
private LogBase m_log;
|
||||
private ScriptServerMain m_ScriptServerMain;
|
||||
public RegionCommManager(ScriptServerMain scm, LogBase logger)
|
||||
{
|
||||
m_ScriptServerMain = scm;
|
||||
m_log = logger;
|
||||
}
|
||||
~RegionCommManager()
|
||||
{
|
||||
Stop();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts listening for region requests
|
||||
/// </summary>
|
||||
public void Start()
|
||||
{
|
||||
// Start listener
|
||||
Stop();
|
||||
listenThread = new Thread(ListenThreadLoop);
|
||||
listenThread.Name = "listenThread";
|
||||
listenThread.IsBackground = true;
|
||||
listenThread.Start();
|
||||
}
|
||||
/// <summary>
|
||||
/// Stops listening for region requests
|
||||
/// </summary>
|
||||
public void Stop()
|
||||
{
|
||||
// Stop listener, clean up
|
||||
if (listenThread != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (listenThread.IsAlive)
|
||||
listenThread.Abort();
|
||||
listenThread.Join(1000); // Wait 1 second for thread to shut down
|
||||
}
|
||||
catch { }
|
||||
listenThread = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void ListenThreadLoop()
|
||||
{
|
||||
// * Listen for requests from regions
|
||||
// * When a request is received:
|
||||
// - Authenticate region
|
||||
// - Authenticate user
|
||||
// - Have correct scriptengine load script
|
||||
// ~ ask scriptengines if they will accept script?
|
||||
// - Add script to shared communication channel towards that region
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using OpenSim.Framework.Console;
|
||||
|
||||
namespace OpenSim.Grid.ScriptServer
|
||||
{
|
||||
// Waiting for incoming script requests from region
|
||||
internal class RegionCommManager
|
||||
{
|
||||
private Thread listenThread;
|
||||
|
||||
private List<RegionConnectionManager> Regions = new List<RegionConnectionManager>();
|
||||
|
||||
private LogBase m_log;
|
||||
private ScriptServerMain m_ScriptServerMain;
|
||||
public RegionCommManager(ScriptServerMain scm, LogBase logger)
|
||||
{
|
||||
m_ScriptServerMain = scm;
|
||||
m_log = logger;
|
||||
}
|
||||
~RegionCommManager()
|
||||
{
|
||||
Stop();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts listening for region requests
|
||||
/// </summary>
|
||||
public void Start()
|
||||
{
|
||||
// Start listener
|
||||
Stop();
|
||||
listenThread = new Thread(ListenThreadLoop);
|
||||
listenThread.Name = "listenThread";
|
||||
listenThread.IsBackground = true;
|
||||
listenThread.Start();
|
||||
}
|
||||
/// <summary>
|
||||
/// Stops listening for region requests
|
||||
/// </summary>
|
||||
public void Stop()
|
||||
{
|
||||
// Stop listener, clean up
|
||||
if (listenThread != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (listenThread.IsAlive)
|
||||
listenThread.Abort();
|
||||
listenThread.Join(1000); // Wait 1 second for thread to shut down
|
||||
}
|
||||
catch { }
|
||||
listenThread = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void ListenThreadLoop()
|
||||
{
|
||||
// * Listen for requests from regions
|
||||
// * When a request is received:
|
||||
// - Authenticate region
|
||||
// - Authenticate user
|
||||
// - Have correct scriptengine load script
|
||||
// ~ ask scriptengines if they will accept script?
|
||||
// - Add script to shared communication channel towards that region
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using OpenSim.Framework.Console;
|
||||
|
||||
using OpenSim.Framework.Console;
|
||||
|
||||
namespace OpenSim.Grid.ScriptServer
|
||||
{
|
||||
internal class ScriptEngineLoader
|
||||
@@ -39,7 +39,7 @@ namespace OpenSim.Grid.ScriptServer
|
||||
|
||||
public ScriptEngineLoader(LogBase logger)
|
||||
{
|
||||
m_log = logger;
|
||||
m_log = logger;
|
||||
}
|
||||
|
||||
public ScriptEngineInterface LoadScriptEngine(string EngineName)
|
||||
@@ -121,5 +121,5 @@ namespace OpenSim.Grid.ScriptServer
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,41 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenSim.Framework.Console;
|
||||
|
||||
namespace OpenSim.Grid.ScriptServer
|
||||
{
|
||||
internal class ScriptEngineManager
|
||||
{
|
||||
private LogBase m_log;
|
||||
private ScriptEngineLoader ScriptEngineLoader;
|
||||
private List<ScriptEngineInterface> scriptEngines = new List<ScriptEngineInterface>();
|
||||
private ScriptServerMain m_ScriptServerMain;
|
||||
|
||||
// Initialize
|
||||
public ScriptEngineManager(ScriptServerMain scm, LogBase logger)
|
||||
{
|
||||
m_ScriptServerMain = scm;
|
||||
m_log = logger;
|
||||
ScriptEngineLoader = new ScriptEngineLoader(m_log);
|
||||
|
||||
// Temp - we should not load during initialize... Loading should be done later.
|
||||
LoadEngine("DotNetScriptEngine");
|
||||
}
|
||||
~ScriptEngineManager()
|
||||
{
|
||||
}
|
||||
|
||||
public void LoadEngine(string engineName)
|
||||
{
|
||||
// Load and add to list of ScriptEngines
|
||||
ScriptEngineInterface sei = ScriptEngineLoader.LoadScriptEngine(engineName);
|
||||
if (sei != null)
|
||||
{
|
||||
scriptEngines.Add(sei);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenSim.Framework.Console;
|
||||
|
||||
namespace OpenSim.Grid.ScriptServer
|
||||
{
|
||||
internal class ScriptEngineManager
|
||||
{
|
||||
private LogBase m_log;
|
||||
private ScriptEngineLoader ScriptEngineLoader;
|
||||
private List<ScriptEngineInterface> scriptEngines = new List<ScriptEngineInterface>();
|
||||
private ScriptServerMain m_ScriptServerMain;
|
||||
|
||||
// Initialize
|
||||
public ScriptEngineManager(ScriptServerMain scm, LogBase logger)
|
||||
{
|
||||
m_ScriptServerMain = scm;
|
||||
m_log = logger;
|
||||
ScriptEngineLoader = new ScriptEngineLoader(m_log);
|
||||
|
||||
// Temp - we should not load during initialize... Loading should be done later.
|
||||
LoadEngine("DotNetScriptEngine");
|
||||
}
|
||||
~ScriptEngineManager()
|
||||
{
|
||||
}
|
||||
|
||||
public void LoadEngine(string engineName)
|
||||
{
|
||||
// Load and add to list of ScriptEngines
|
||||
ScriptEngineInterface sei = ScriptEngineLoader.LoadScriptEngine(engineName);
|
||||
if (sei != null)
|
||||
{
|
||||
scriptEngines.Add(sei);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,48 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Framework.Utilities;
|
||||
|
||||
namespace OpenSim.Grid.ScriptServer
|
||||
{
|
||||
public class ScriptServerMain : conscmd_callback
|
||||
{
|
||||
private readonly string m_logFilename = ("region-console.log");
|
||||
internal RegionCommManager RegionScriptDaemon; // Listen for incoming from region
|
||||
internal ScriptEngineManager ScriptEngines; // Loads scriptengines
|
||||
private LogBase m_log;
|
||||
|
||||
public ScriptServerMain()
|
||||
{
|
||||
m_log = CreateLog();
|
||||
|
||||
RegionScriptDaemon = new RegionCommManager(this, m_log);
|
||||
ScriptEngines = new ScriptEngineManager(this, m_log);
|
||||
|
||||
}
|
||||
|
||||
~ScriptServerMain()
|
||||
{
|
||||
}
|
||||
|
||||
protected LogBase CreateLog()
|
||||
{
|
||||
if (!Directory.Exists(Util.logDir()))
|
||||
{
|
||||
Directory.CreateDirectory(Util.logDir());
|
||||
}
|
||||
|
||||
return new LogBase((Path.Combine(Util.logDir(), m_logFilename)), "Region", this, false);
|
||||
}
|
||||
|
||||
public void RunCmd(string command, string[] cmdparams)
|
||||
{
|
||||
}
|
||||
public void Show(string ShowWhat)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Framework.Utilities;
|
||||
|
||||
namespace OpenSim.Grid.ScriptServer
|
||||
{
|
||||
public class ScriptServerMain : conscmd_callback
|
||||
{
|
||||
private readonly string m_logFilename = ("region-console.log");
|
||||
internal RegionCommManager RegionScriptDaemon; // Listen for incoming from region
|
||||
internal ScriptEngineManager ScriptEngines; // Loads scriptengines
|
||||
private LogBase m_log;
|
||||
|
||||
public ScriptServerMain()
|
||||
{
|
||||
m_log = CreateLog();
|
||||
|
||||
RegionScriptDaemon = new RegionCommManager(this, m_log);
|
||||
ScriptEngines = new ScriptEngineManager(this, m_log);
|
||||
|
||||
}
|
||||
|
||||
~ScriptServerMain()
|
||||
{
|
||||
}
|
||||
|
||||
protected LogBase CreateLog()
|
||||
{
|
||||
if (!Directory.Exists(Util.logDir()))
|
||||
{
|
||||
Directory.CreateDirectory(Util.logDir());
|
||||
}
|
||||
|
||||
return new LogBase((Path.Combine(Util.logDir(), m_logFilename)), "Region", this, false);
|
||||
}
|
||||
|
||||
public void RunCmd(string command, string[] cmdparams)
|
||||
{
|
||||
}
|
||||
public void Show(string ShowWhat)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,96 +1,96 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Net;
|
||||
using Nwc.XmlRpc;
|
||||
using OpenSim.Framework.Data;
|
||||
using OpenSim.Framework.UserManagement;
|
||||
using OpenSim.Framework.Utilities;
|
||||
using OpenSim.Framework.Configuration;
|
||||
using OpenSim.Framework.Types;
|
||||
|
||||
namespace OpenSim.Grid.UserServer
|
||||
{
|
||||
public class UserLoginService : LoginService
|
||||
{
|
||||
public UserConfig m_config;
|
||||
|
||||
public UserLoginService(UserManagerBase userManager, UserConfig config, string welcomeMess)
|
||||
: base(userManager, welcomeMess)
|
||||
{
|
||||
m_config = config;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Customises the login response and fills in missing values.
|
||||
/// </summary>
|
||||
/// <param name="response">The existing response</param>
|
||||
/// <param name="theUser">The user profile</param>
|
||||
public override void CustomiseResponse(LoginResponse response, UserProfileData theUser)
|
||||
{
|
||||
// Load information from the gridserver
|
||||
SimProfileData SimInfo = new SimProfileData();
|
||||
SimInfo = SimInfo.RequestSimProfileData(theUser.currentAgent.currentHandle, m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey);
|
||||
|
||||
// Customise the response
|
||||
// Home Location
|
||||
response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * 256).ToString() + ",r" + (SimInfo.regionLocY * 256).ToString() + "], " +
|
||||
"'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " +
|
||||
"'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}";
|
||||
|
||||
// Destination
|
||||
Console.WriteLine("CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " + SimInfo.regionLocY);
|
||||
response.SimAddress = Util.GetHostFromDNS(SimInfo.serverIP).ToString();
|
||||
response.SimPort = (Int32)SimInfo.serverPort;
|
||||
response.RegionX = SimInfo.regionLocX;
|
||||
response.RegionY = SimInfo.regionLocY;
|
||||
|
||||
//Not sure if the + "/CAPS/" should in fact be +"CAPS/" depending if there is already a / as part of httpServerURI
|
||||
string capsPath = Util.GetRandomCapsPath();
|
||||
response.SeedCapability = SimInfo.httpServerURI + "CAPS/" + capsPath + "0000/";
|
||||
|
||||
// Notify the target of an incoming user
|
||||
Console.WriteLine("Notifying " + SimInfo.regionName + " (" + SimInfo.serverURI + ")");
|
||||
|
||||
// Prepare notification
|
||||
Hashtable SimParams = new Hashtable();
|
||||
SimParams["session_id"] = theUser.currentAgent.sessionID.ToString();
|
||||
SimParams["secure_session_id"] = theUser.currentAgent.secureSessionID.ToString();
|
||||
SimParams["firstname"] = theUser.username;
|
||||
SimParams["lastname"] = theUser.surname;
|
||||
SimParams["agent_id"] = theUser.UUID.ToString();
|
||||
SimParams["circuit_code"] = (Int32)Convert.ToUInt32(response.CircuitCode);
|
||||
SimParams["startpos_x"] = theUser.currentAgent.currentPos.X.ToString();
|
||||
SimParams["startpos_y"] = theUser.currentAgent.currentPos.Y.ToString();
|
||||
SimParams["startpos_z"] = theUser.currentAgent.currentPos.Z.ToString();
|
||||
SimParams["regionhandle"] = theUser.currentAgent.currentHandle.ToString();
|
||||
SimParams["caps_path"] = capsPath;
|
||||
ArrayList SendParams = new ArrayList();
|
||||
SendParams.Add(SimParams);
|
||||
|
||||
// Update agent with target sim
|
||||
theUser.currentAgent.currentRegion = SimInfo.UUID;
|
||||
theUser.currentAgent.currentHandle = SimInfo.regionHandle;
|
||||
|
||||
System.Console.WriteLine("Informing region --> " + SimInfo.httpServerURI);
|
||||
// Send
|
||||
try
|
||||
{
|
||||
XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams);
|
||||
XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000);
|
||||
}
|
||||
catch( WebException e )
|
||||
{
|
||||
switch( e.Status )
|
||||
{
|
||||
case WebExceptionStatus.Timeout:
|
||||
//TODO: Send him to nearby or default region instead
|
||||
break;
|
||||
|
||||
default:
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Net;
|
||||
using Nwc.XmlRpc;
|
||||
using OpenSim.Framework.Data;
|
||||
using OpenSim.Framework.UserManagement;
|
||||
using OpenSim.Framework.Utilities;
|
||||
using OpenSim.Framework.Configuration;
|
||||
using OpenSim.Framework.Types;
|
||||
|
||||
namespace OpenSim.Grid.UserServer
|
||||
{
|
||||
public class UserLoginService : LoginService
|
||||
{
|
||||
public UserConfig m_config;
|
||||
|
||||
public UserLoginService(UserManagerBase userManager, UserConfig config, string welcomeMess)
|
||||
: base(userManager, welcomeMess)
|
||||
{
|
||||
m_config = config;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Customises the login response and fills in missing values.
|
||||
/// </summary>
|
||||
/// <param name="response">The existing response</param>
|
||||
/// <param name="theUser">The user profile</param>
|
||||
public override void CustomiseResponse(LoginResponse response, UserProfileData theUser)
|
||||
{
|
||||
// Load information from the gridserver
|
||||
SimProfileData SimInfo = new SimProfileData();
|
||||
SimInfo = SimInfo.RequestSimProfileData(theUser.currentAgent.currentHandle, m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey);
|
||||
|
||||
// Customise the response
|
||||
// Home Location
|
||||
response.Home = "{'region_handle':[r" + (SimInfo.regionLocX * 256).ToString() + ",r" + (SimInfo.regionLocY * 256).ToString() + "], " +
|
||||
"'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " +
|
||||
"'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}";
|
||||
|
||||
// Destination
|
||||
Console.WriteLine("CUSTOMISERESPONSE: Region X: " + SimInfo.regionLocX + "; Region Y: " + SimInfo.regionLocY);
|
||||
response.SimAddress = Util.GetHostFromDNS(SimInfo.serverIP).ToString();
|
||||
response.SimPort = (Int32)SimInfo.serverPort;
|
||||
response.RegionX = SimInfo.regionLocX;
|
||||
response.RegionY = SimInfo.regionLocY;
|
||||
|
||||
//Not sure if the + "/CAPS/" should in fact be +"CAPS/" depending if there is already a / as part of httpServerURI
|
||||
string capsPath = Util.GetRandomCapsPath();
|
||||
response.SeedCapability = SimInfo.httpServerURI + "CAPS/" + capsPath + "0000/";
|
||||
|
||||
// Notify the target of an incoming user
|
||||
Console.WriteLine("Notifying " + SimInfo.regionName + " (" + SimInfo.serverURI + ")");
|
||||
|
||||
// Prepare notification
|
||||
Hashtable SimParams = new Hashtable();
|
||||
SimParams["session_id"] = theUser.currentAgent.sessionID.ToString();
|
||||
SimParams["secure_session_id"] = theUser.currentAgent.secureSessionID.ToString();
|
||||
SimParams["firstname"] = theUser.username;
|
||||
SimParams["lastname"] = theUser.surname;
|
||||
SimParams["agent_id"] = theUser.UUID.ToString();
|
||||
SimParams["circuit_code"] = (Int32)Convert.ToUInt32(response.CircuitCode);
|
||||
SimParams["startpos_x"] = theUser.currentAgent.currentPos.X.ToString();
|
||||
SimParams["startpos_y"] = theUser.currentAgent.currentPos.Y.ToString();
|
||||
SimParams["startpos_z"] = theUser.currentAgent.currentPos.Z.ToString();
|
||||
SimParams["regionhandle"] = theUser.currentAgent.currentHandle.ToString();
|
||||
SimParams["caps_path"] = capsPath;
|
||||
ArrayList SendParams = new ArrayList();
|
||||
SendParams.Add(SimParams);
|
||||
|
||||
// Update agent with target sim
|
||||
theUser.currentAgent.currentRegion = SimInfo.UUID;
|
||||
theUser.currentAgent.currentHandle = SimInfo.regionHandle;
|
||||
|
||||
System.Console.WriteLine("Informing region --> " + SimInfo.httpServerURI);
|
||||
// Send
|
||||
try
|
||||
{
|
||||
XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams);
|
||||
XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000);
|
||||
}
|
||||
catch( WebException e )
|
||||
{
|
||||
switch( e.Status )
|
||||
{
|
||||
case WebExceptionStatus.Timeout:
|
||||
//TODO: Send him to nearby or default region instead
|
||||
break;
|
||||
|
||||
default:
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user