* Removed some more fields from CommunicationsLocal

* added OnLoginToRegion to CommunicationsLocal
afrisby
lbsa71 2007-09-24 23:58:43 +00:00
parent 4e01aa4879
commit 3ac43d0120
5 changed files with 196 additions and 208 deletions

View File

@ -38,43 +38,26 @@ using OpenSim.Framework.Utilities;
namespace OpenSim.Region.Communications.Local namespace OpenSim.Region.Communications.Local
{ {
public class CommunicationsLocal : CommunicationsManager public class CommunicationsLocal : CommunicationsManager
{ {
public LocalBackEndServices InstanceServices;
public LocalLoginService LoginServices;
protected LocalSettings m_settings;
protected CommunicationsLocal(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache)
: base(serversInfo, httpServer, assetCache)
{
}
public CommunicationsLocal(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache, LocalSettings settings) public CommunicationsLocal(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache, LocalSettings settings)
: base(serversInfo, httpServer, assetCache) : base(serversInfo, httpServer, assetCache)
{ {
m_settings = settings;
LocalInventoryService inventoryService = new LocalInventoryService(); LocalInventoryService inventoryService = new LocalInventoryService();
inventoryService.AddPlugin(m_settings.InventoryPlugin); inventoryService.AddPlugin(settings.InventoryPlugin);
m_inventoryService = inventoryService; m_inventoryService = inventoryService;
LocalUserServices userService = new LocalUserServices(this, serversInfo); LocalUserServices userService = new LocalUserServices(this, serversInfo);
userService.AddPlugin(m_settings.UserDatabasePlugin); userService.AddPlugin(settings.UserDatabasePlugin);
m_userService = userService; m_userService = userService;
InstanceServices = new LocalBackEndServices(); LocalBackEndServices backendService = new LocalBackEndServices();
m_gridService = InstanceServices; m_gridService = backendService;
m_interRegion = InstanceServices; m_interRegion = backendService;
LoginServices = new LocalLoginService(userService, m_settings.WelcomeMessage, this, serversInfo, m_settings.AccountAuthentication); LocalLoginService loginService = new LocalLoginService(userService, settings.WelcomeMessage, this, serversInfo, settings.AccountAuthentication);
httpServer.AddXmlRPCHandler("login_to_simulator", LoginServices.XmlRpcLoginMethod); loginService.OnLoginToRegion += backendService.AddNewSession;
}
internal void InformRegionOfLogin(ulong regionHandle, Login login) httpServer.AddXmlRPCHandler("login_to_simulator", loginService.XmlRpcLoginMethod);
{
this.InstanceServices.AddNewSession(regionHandle, login);
} }
public void doCreate(string[] cmmdParams) public void doCreate(string[] cmmdParams)

View File

@ -187,7 +187,7 @@ namespace OpenSim.Region.Communications.Local
/// <param name="regionHandle"></param> /// <param name="regionHandle"></param>
/// <param name="loginData"></param> /// <param name="loginData"></param>
/// <returns></returns> /// <returns></returns>
public bool AddNewSession(ulong regionHandle, Login loginData) public void AddNewSession(ulong regionHandle, Login loginData)
{ {
AgentCircuitData agent = new AgentCircuitData(); AgentCircuitData agent = new AgentCircuitData();
agent.AgentID = loginData.Agent; agent.AgentID = loginData.Agent;
@ -204,11 +204,7 @@ namespace OpenSim.Region.Communications.Local
if (this.regionHosts.ContainsKey(regionHandle)) if (this.regionHosts.ContainsKey(regionHandle))
{ {
this.regionHosts[regionHandle].TriggerExpectUser(regionHandle, agent); this.regionHosts[regionHandle].TriggerExpectUser(regionHandle, agent);
return true;
} }
// region not found
return false;
} }
} }
} }

View File

@ -1,166 +1,173 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using libsecondlife; using libsecondlife;
using OpenSim.Framework.Communications; using OpenSim.Framework.Communications;
using OpenSim.Framework.Data; using OpenSim.Framework.Data;
using OpenSim.Framework.Types; using OpenSim.Framework.Types;
using OpenSim.Framework.UserManagement; using OpenSim.Framework.UserManagement;
using OpenSim.Framework.Utilities; using OpenSim.Framework.Utilities;
using OpenSim.Framework.Inventory; using OpenSim.Framework.Inventory;
namespace OpenSim.Region.Communications.Local namespace OpenSim.Region.Communications.Local
{ {
public class LocalLoginService : LoginService public delegate void LoginToRegionEvent(ulong regionHandle, Login login);
{
private CommunicationsLocal m_Parent; public class LocalLoginService : LoginService
{
private NetworkServersInfo serversInfo; private CommunicationsLocal m_Parent;
private uint defaultHomeX;
private uint defaultHomeY; private NetworkServersInfo serversInfo;
private bool authUsers = false; private uint defaultHomeX;
private uint defaultHomeY;
public LocalLoginService(UserManagerBase userManager, string welcomeMess, CommunicationsLocal parent, NetworkServersInfo serversInfo, bool authenticate) private bool authUsers = false;
: base(userManager, welcomeMess)
{ public event LoginToRegionEvent OnLoginToRegion;
m_Parent = parent;
this.serversInfo = serversInfo; public LocalLoginService(UserManagerBase userManager, string welcomeMess, CommunicationsLocal parent, NetworkServersInfo serversInfo, bool authenticate)
defaultHomeX = this.serversInfo.DefaultHomeLocX; : base(userManager, welcomeMess)
defaultHomeY = this.serversInfo.DefaultHomeLocY; {
this.authUsers = authenticate; m_Parent = parent;
} this.serversInfo = serversInfo;
defaultHomeX = this.serversInfo.DefaultHomeLocX;
defaultHomeY = this.serversInfo.DefaultHomeLocY;
public override UserProfileData GetTheUser(string firstname, string lastname) this.authUsers = authenticate;
{ }
UserProfileData profile = this.m_userManager.GetUserProfile(firstname, lastname);
if (profile != null)
{ public override UserProfileData GetTheUser(string firstname, string lastname)
{
return profile; UserProfileData profile = this.m_userManager.GetUserProfile(firstname, lastname);
} if (profile != null)
{
if (!authUsers)
{ return profile;
//no current user account so make one }
Console.WriteLine("No User account found so creating a new one ");
this.m_userManager.AddUserProfile(firstname, lastname, "test", defaultHomeX, defaultHomeY); if (!authUsers)
{
profile = this.m_userManager.GetUserProfile(firstname, lastname); //no current user account so make one
if (profile != null) Console.WriteLine("No User account found so creating a new one ");
{ this.m_userManager.AddUserProfile(firstname, lastname, "test", defaultHomeX, defaultHomeY);
m_Parent.InventoryService.CreateNewUserInventory(profile.UUID);
} profile = this.m_userManager.GetUserProfile(firstname, lastname);
if (profile != null)
return profile; {
} m_Parent.InventoryService.CreateNewUserInventory(profile.UUID);
return null; }
}
return profile;
public override bool AuthenticateUser(UserProfileData profile, string password) }
{ return null;
if (!authUsers) }
{
//for now we will accept any password in sandbox mode public override bool AuthenticateUser(UserProfileData profile, string password)
Console.WriteLine("authorising user"); {
return true; if (!authUsers)
} {
else //for now we will accept any password in sandbox mode
{ Console.WriteLine("authorising user");
Console.WriteLine("Authenticating " + profile.username + " " + profile.surname); return true;
}
password = password.Remove(0, 3); //remove $1$ else
{
string s = Util.Md5Hash(password + ":" + profile.passwordSalt); Console.WriteLine("Authenticating " + profile.username + " " + profile.surname);
return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase); password = password.Remove(0, 3); //remove $1$
}
} string s = Util.Md5Hash(password + ":" + profile.passwordSalt);
public override void CustomiseResponse(LoginResponse response, UserProfileData theUser) return profile.passwordHash.Equals(s.ToString(), StringComparison.InvariantCultureIgnoreCase);
{ }
ulong currentRegion = theUser.currentAgent.currentHandle; }
RegionInfo reg = m_Parent.GridService.RequestNeighbourInfo(currentRegion);
public override void CustomiseResponse(LoginResponse response, UserProfileData theUser)
if (reg != null) {
{ ulong currentRegion = theUser.currentAgent.currentHandle;
response.Home = "{'region_handle':[r" + (reg.RegionLocX * 256).ToString() + ",r" + (reg.RegionLocY * 256).ToString() + "], " + RegionInfo reg = m_Parent.GridService.RequestNeighbourInfo(currentRegion);
"'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() + "]}"; if (reg != null)
string capsPath = Util.GetRandomCapsPath(); {
response.SimAddress = reg.ExternalEndPoint.Address.ToString(); response.Home = "{'region_handle':[r" + (reg.RegionLocX * 256).ToString() + ",r" + (reg.RegionLocY * 256).ToString() + "], " +
response.SimPort = (Int32)reg.ExternalEndPoint.Port; "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " +
response.RegionX = reg.RegionLocX; "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}";
response.RegionY = reg.RegionLocY; string capsPath = Util.GetRandomCapsPath();
response.SimAddress = reg.ExternalEndPoint.Address.ToString();
response.SeedCapability = "http://" + reg.ExternalHostName + ":" + this.serversInfo.HttpListenerPort.ToString() + "/CAPS/" + capsPath + "0000/"; response.SimPort = (Int32)reg.ExternalEndPoint.Port;
// response.SeedCapability = "http://" + reg.ExternalHostName + ":" + this.serversInfo.HttpListenerPort.ToString() + "/CapsSeed/" + capsPath + "0000/"; response.RegionX = reg.RegionLocX;
theUser.currentAgent.currentRegion = reg.SimUUID; response.RegionY = reg.RegionLocY;
theUser.currentAgent.currentHandle = reg.RegionHandle;
response.SeedCapability = "http://" + reg.ExternalHostName + ":" + this.serversInfo.HttpListenerPort.ToString() + "/CAPS/" + capsPath + "0000/";
Login _login = new Login(); // response.SeedCapability = "http://" + reg.ExternalHostName + ":" + this.serversInfo.HttpListenerPort.ToString() + "/CapsSeed/" + capsPath + "0000/";
//copy data to login object theUser.currentAgent.currentRegion = reg.SimUUID;
_login.First = response.Firstname; theUser.currentAgent.currentHandle = reg.RegionHandle;
_login.Last = response.Lastname;
_login.Agent = response.AgentID; Login _login = new Login();
_login.Session = response.SessionID; //copy data to login object
_login.SecureSession = response.SecureSessionID; _login.First = response.Firstname;
_login.CircuitCode = (uint)response.CircuitCode; _login.Last = response.Lastname;
_login.CapsPath = capsPath; _login.Agent = response.AgentID;
_login.Session = response.SessionID;
m_Parent.InformRegionOfLogin(currentRegion, _login); _login.SecureSession = response.SecureSessionID;
} _login.CircuitCode = (uint)response.CircuitCode;
else _login.CapsPath = capsPath;
{
Console.WriteLine("not found region " + currentRegion); if( OnLoginToRegion != null )
} {
OnLoginToRegion(currentRegion, _login);
} }
}
protected override InventoryData CreateInventoryData(LLUUID userID) else
{ {
List<InventoryFolderBase> folders = m_Parent.InventoryService.RequestFirstLevelFolders(userID); Console.WriteLine("not found region " + currentRegion);
if (folders.Count > 0) }
{
LLUUID rootID = LLUUID.Zero; }
ArrayList AgentInventoryArray = new ArrayList();
Hashtable TempHash; protected override InventoryData CreateInventoryData(LLUUID userID)
foreach (InventoryFolderBase InvFolder in folders) {
{ List<InventoryFolderBase> folders = m_Parent.InventoryService.RequestFirstLevelFolders(userID);
if (InvFolder.parentID == LLUUID.Zero) if (folders.Count > 0)
{ {
rootID = InvFolder.folderID; LLUUID rootID = LLUUID.Zero;
} ArrayList AgentInventoryArray = new ArrayList();
TempHash = new Hashtable(); Hashtable TempHash;
TempHash["name"] = InvFolder.name; foreach (InventoryFolderBase InvFolder in folders)
TempHash["parent_id"] = InvFolder.parentID.ToStringHyphenated(); {
TempHash["version"] = (Int32)InvFolder.version; if (InvFolder.parentID == LLUUID.Zero)
TempHash["type_default"] = (Int32)InvFolder.type; {
TempHash["folder_id"] = InvFolder.folderID.ToStringHyphenated(); rootID = InvFolder.folderID;
AgentInventoryArray.Add(TempHash); }
} TempHash = new Hashtable();
return new InventoryData(AgentInventoryArray, rootID); TempHash["name"] = InvFolder.name;
} TempHash["parent_id"] = InvFolder.parentID.ToStringHyphenated();
else TempHash["version"] = (Int32)InvFolder.version;
{ TempHash["type_default"] = (Int32)InvFolder.type;
AgentInventory userInventory = new AgentInventory(); TempHash["folder_id"] = InvFolder.folderID.ToStringHyphenated();
userInventory.CreateRootFolder(userID, false); AgentInventoryArray.Add(TempHash);
}
ArrayList AgentInventoryArray = new ArrayList(); return new InventoryData(AgentInventoryArray, rootID);
Hashtable TempHash; }
foreach (OpenSim.Framework.Inventory.InventoryFolder InvFolder in userInventory.InventoryFolders.Values) else
{ {
TempHash = new Hashtable(); AgentInventory userInventory = new AgentInventory();
TempHash["name"] = InvFolder.FolderName; userInventory.CreateRootFolder(userID, false);
TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated();
TempHash["version"] = (Int32)InvFolder.Version; ArrayList AgentInventoryArray = new ArrayList();
TempHash["type_default"] = (Int32)InvFolder.DefaultType; Hashtable TempHash;
TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); foreach (OpenSim.Framework.Inventory.InventoryFolder InvFolder in userInventory.InventoryFolders.Values)
AgentInventoryArray.Add(TempHash); {
} TempHash = new Hashtable();
TempHash["name"] = InvFolder.FolderName;
return new InventoryData(AgentInventoryArray, userInventory.InventoryRoot.FolderID); TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated();
} TempHash["version"] = (Int32)InvFolder.Version;
} TempHash["type_default"] = (Int32)InvFolder.DefaultType;
} TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated();
} AgentInventoryArray.Add(TempHash);
}
return new InventoryData(AgentInventoryArray, userInventory.InventoryRoot.FolderID);
}
}
}
}

View File

@ -70,7 +70,7 @@ namespace OpenSim.Region.Communications.OGS1
// Send Request // Send Request
XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams); XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams);
XmlRpcResponse GridResp = GridReq.Send(serversInfo.GridURL, 3000); XmlRpcResponse GridResp = GridReq.Send(serversInfo.GridURL, 10000);
Hashtable GridRespData = (Hashtable)GridResp.Value; Hashtable GridRespData = (Hashtable)GridResp.Value;
Hashtable griddatahash = GridRespData; Hashtable griddatahash = GridRespData;
@ -109,18 +109,20 @@ namespace OpenSim.Region.Communications.OGS1
List<RegionInfo> neighbours = new List<RegionInfo>(); List<RegionInfo> neighbours = new List<RegionInfo>();
foreach (ArrayList a in respData.Values) foreach (ArrayList neighboursList in respData.Values)
{ {
foreach (Hashtable n in a) foreach (Hashtable neighbourData in neighboursList)
{ {
uint regX = Convert.ToUInt32(n["x"]); uint regX = Convert.ToUInt32(neighbourData["x"]);
uint regY = Convert.ToUInt32(n["y"]); uint regY = Convert.ToUInt32(neighbourData["y"]);
if ((regionInfo.RegionLocX != regX) || (regionInfo.RegionLocY != regY)) if ((regionInfo.RegionLocX != regX) || (regionInfo.RegionLocY != regY))
{ {
string externalIpStr = OpenSim.Framework.Utilities.Util.GetHostFromDNS((string)n["sim_ip"]).ToString(); string simIp = (string)neighbourData["sim_ip"];
uint port = Convert.ToUInt32(n["sim_port"]);
string externalUri = (string)n["sim_uri"];
uint port = Convert.ToUInt32(neighbourData["sim_port"]);
string externalUri = (string)neighbourData["sim_uri"];
string externalIpStr = OpenSim.Framework.Utilities.Util.GetHostFromDNS(simIp).ToString();
IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(externalIpStr), (int)port); IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(externalIpStr), (int)port);
string neighbourExternalUri = externalUri; string neighbourExternalUri = externalUri;
RegionInfo neighbour = new RegionInfo(regX, regY, neighbourInternalEndPoint, externalIpStr); RegionInfo neighbour = new RegionInfo(regX, regY, neighbourInternalEndPoint, externalIpStr);
@ -128,10 +130,10 @@ namespace OpenSim.Region.Communications.OGS1
//OGS1 //OGS1
//neighbour.RegionHandle = (ulong)n["regionhandle"]; is now calculated locally //neighbour.RegionHandle = (ulong)n["regionhandle"]; is now calculated locally
neighbour.RegionName = (string)n["name"]; neighbour.RegionName = (string)neighbourData["name"];
//OGS1+ //OGS1+
neighbour.SimUUID = (string)n["uuid"]; neighbour.SimUUID = new LLUUID((string) neighbourData["uuid"]);
neighbours.Add(neighbour); neighbours.Add(neighbour);
} }

View File

@ -1,10 +1,10 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using libsecondlife; using libsecondlife;
using OpenSim.Framework.Communications; using OpenSim.Framework.Communications;
using OpenSim.Framework.Data; using OpenSim.Framework.Data;
using InventoryFolder = OpenSim.Framework.Communications.Caches.InventoryFolder; using InventoryFolder = OpenSim.Framework.Communications.Caches.InventoryFolder;
namespace OpenSim.Region.Communications.OGS1 namespace OpenSim.Region.Communications.OGS1
{ {
public class OGS1InventoryService : IInventoryServices public class OGS1InventoryService : IInventoryServices