Some continuation of lbsa71's refactoring of the CommunicationsManager.
parent
d36316e1c9
commit
9b1eefbcde
|
@ -25,6 +25,7 @@
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
using System;
|
||||||
using libsecondlife;
|
using libsecondlife;
|
||||||
using OpenSim.Framework.Communications.Cache;
|
using OpenSim.Framework.Communications.Cache;
|
||||||
using OpenSim.Framework.Communications.Caches;
|
using OpenSim.Framework.Communications.Caches;
|
||||||
|
@ -32,6 +33,8 @@ using OpenSim.Framework.Data;
|
||||||
using OpenSim.Framework.Interfaces;
|
using OpenSim.Framework.Interfaces;
|
||||||
using OpenSim.Framework.Servers;
|
using OpenSim.Framework.Servers;
|
||||||
using OpenSim.Framework.Types;
|
using OpenSim.Framework.Types;
|
||||||
|
using OpenSim.Framework.Console;
|
||||||
|
using OpenSim.Framework.Utilities;
|
||||||
|
|
||||||
namespace OpenSim.Framework.Communications
|
namespace OpenSim.Framework.Communications
|
||||||
{
|
{
|
||||||
|
@ -93,6 +96,58 @@ namespace OpenSim.Framework.Communications
|
||||||
m_transactionsManager = new AssetTransactionManager(this);
|
m_transactionsManager = new AssetTransactionManager(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void doCreate(string[] cmmdParams)
|
||||||
|
{
|
||||||
|
switch (cmmdParams[0])
|
||||||
|
{
|
||||||
|
case "user":
|
||||||
|
string firstName;
|
||||||
|
string lastName;
|
||||||
|
string password;
|
||||||
|
uint regX = 1000;
|
||||||
|
uint regY = 1000;
|
||||||
|
|
||||||
|
if (cmmdParams.Length < 2)
|
||||||
|
{
|
||||||
|
|
||||||
|
firstName = MainLog.Instance.CmdPrompt("First name", "Default");
|
||||||
|
lastName = MainLog.Instance.CmdPrompt("Last name", "User");
|
||||||
|
password = MainLog.Instance.PasswdPrompt("Password");
|
||||||
|
regX = Convert.ToUInt32(MainLog.Instance.CmdPrompt("Start Region X", "1000"));
|
||||||
|
regY = Convert.ToUInt32(MainLog.Instance.CmdPrompt("Start Region Y", "1000"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
firstName = cmmdParams[1];
|
||||||
|
lastName = cmmdParams[2];
|
||||||
|
password = cmmdParams[3];
|
||||||
|
regX = Convert.ToUInt32(cmmdParams[4]);
|
||||||
|
regY = Convert.ToUInt32(cmmdParams[5]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
AddUser(firstName, lastName, password, regX, regY);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public LLUUID AddUser(string firstName, string lastName, string password, uint regX, uint regY)
|
||||||
|
{
|
||||||
|
string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + "");
|
||||||
|
|
||||||
|
m_userService.AddUserProfile(firstName, lastName, md5PasswdHash, regX, regY);
|
||||||
|
UserProfileData userProf = UserService.GetUserProfile(firstName, lastName);
|
||||||
|
if (userProf == null)
|
||||||
|
{
|
||||||
|
return LLUUID.Zero;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.m_inventoryService.CreateNewUserInventory(userProf.UUID);
|
||||||
|
System.Console.WriteLine("Created new inventory set for " + firstName + " " + lastName);
|
||||||
|
return userProf.UUID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region Packet Handlers
|
#region Packet Handlers
|
||||||
|
|
||||||
|
|
|
@ -108,6 +108,7 @@ namespace OpenSim
|
||||||
}
|
}
|
||||||
|
|
||||||
ReadConfigSettings(startupSource);
|
ReadConfigSettings(startupSource);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void ReadConfigSettings(IConfigSource configSource)
|
protected void ReadConfigSettings(IConfigSource configSource)
|
||||||
|
@ -145,6 +146,7 @@ namespace OpenSim
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public override void StartUp()
|
public override void StartUp()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!Directory.Exists(Util.logDir()))
|
if (!Directory.Exists(Util.logDir()))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(Util.logDir());
|
Directory.CreateDirectory(Util.logDir());
|
||||||
|
@ -157,14 +159,17 @@ namespace OpenSim
|
||||||
|
|
||||||
if (m_sandbox)
|
if (m_sandbox)
|
||||||
{
|
{
|
||||||
CommunicationsLocal.LocalSettings settings = new CommunicationsLocal.LocalSettings(standaloneWelcomeMessage, standaloneAuthenticate, standaloneInventoryPlugin);
|
CommunicationsLocal.LocalSettings settings = new CommunicationsLocal.LocalSettings(standaloneWelcomeMessage, standaloneAuthenticate);
|
||||||
|
|
||||||
LocalInventoryService inventoryService = new LocalInventoryService();
|
LocalInventoryService inventoryService = new LocalInventoryService();
|
||||||
|
inventoryService.AddPlugin(standaloneInventoryPlugin);
|
||||||
|
|
||||||
LocalUserServices userService = new LocalUserServices(m_networkServersInfo, m_networkServersInfo.DefaultHomeLocX, m_networkServersInfo.DefaultHomeLocY, inventoryService );
|
LocalUserServices userService = new LocalUserServices(m_networkServersInfo, m_networkServersInfo.DefaultHomeLocX, m_networkServersInfo.DefaultHomeLocY, inventoryService );
|
||||||
userService.AddPlugin( standaloneUserPlugin );
|
userService.AddPlugin( standaloneUserPlugin );
|
||||||
|
|
||||||
CommunicationsLocal localComms = new CommunicationsLocal(m_networkServersInfo, m_httpServer, m_assetCache, settings, userService);
|
CommunicationsLocal localComms = new CommunicationsLocal(m_networkServersInfo, m_httpServer, m_assetCache, settings, userService, inventoryService);
|
||||||
m_commsManager = localComms;
|
m_commsManager = localComms;
|
||||||
|
|
||||||
if (standaloneAuthenticate)
|
if (standaloneAuthenticate)
|
||||||
{
|
{
|
||||||
this.CreateAccount = localComms.doCreate;
|
this.CreateAccount = localComms.doCreate;
|
||||||
|
|
|
@ -39,13 +39,10 @@ namespace OpenSim.Region.Communications.Local
|
||||||
{
|
{
|
||||||
public class CommunicationsLocal : CommunicationsManager
|
public class CommunicationsLocal : CommunicationsManager
|
||||||
{
|
{
|
||||||
public CommunicationsLocal(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache, LocalSettings settings, LocalUserServices userService)
|
public CommunicationsLocal(NetworkServersInfo serversInfo, BaseHttpServer httpServer, AssetCache assetCache, LocalSettings settings, LocalUserServices userService, LocalInventoryService inventoryService)
|
||||||
: base(serversInfo, httpServer, assetCache)
|
: base(serversInfo, httpServer, assetCache)
|
||||||
{
|
{
|
||||||
LocalInventoryService inventoryService = new LocalInventoryService();
|
|
||||||
inventoryService.AddPlugin(settings.InventoryPlugin);
|
|
||||||
m_inventoryService = inventoryService;
|
m_inventoryService = inventoryService;
|
||||||
|
|
||||||
m_userService = userService;
|
m_userService = userService;
|
||||||
|
|
||||||
LocalBackEndServices backendService = new LocalBackEndServices();
|
LocalBackEndServices backendService = new LocalBackEndServices();
|
||||||
|
@ -58,70 +55,17 @@ namespace OpenSim.Region.Communications.Local
|
||||||
httpServer.AddXmlRPCHandler("login_to_simulator", loginService.XmlRpcLoginMethod);
|
httpServer.AddXmlRPCHandler("login_to_simulator", loginService.XmlRpcLoginMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doCreate(string[] cmmdParams)
|
|
||||||
{
|
|
||||||
switch (cmmdParams[0])
|
|
||||||
{
|
|
||||||
case "user":
|
|
||||||
string firstName;
|
|
||||||
string lastName;
|
|
||||||
string password;
|
|
||||||
uint regX = 1000;
|
|
||||||
uint regY = 1000;
|
|
||||||
|
|
||||||
if (cmmdParams.Length < 2)
|
|
||||||
{
|
|
||||||
|
|
||||||
firstName = MainLog.Instance.CmdPrompt("First name", "Default");
|
|
||||||
lastName = MainLog.Instance.CmdPrompt("Last name", "User");
|
|
||||||
password = MainLog.Instance.PasswdPrompt("Password");
|
|
||||||
regX = Convert.ToUInt32(MainLog.Instance.CmdPrompt("Start Region X", "1000"));
|
|
||||||
regY = Convert.ToUInt32(MainLog.Instance.CmdPrompt("Start Region Y", "1000"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
firstName = cmmdParams[1];
|
|
||||||
lastName = cmmdParams[2];
|
|
||||||
password = cmmdParams[3];
|
|
||||||
regX = Convert.ToUInt32(cmmdParams[4]);
|
|
||||||
regY = Convert.ToUInt32(cmmdParams[5]);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
AddUser(firstName, lastName, password, regX, regY);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public LLUUID AddUser(string firstName, string lastName, string password, uint regX, uint regY)
|
|
||||||
{
|
|
||||||
string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + "");
|
|
||||||
|
|
||||||
m_userService.AddUserProfile(firstName, lastName, md5PasswdHash, regX, regY);
|
|
||||||
UserProfileData userProf = this.UserService.GetUserProfile(firstName, lastName);
|
|
||||||
if (userProf == null)
|
|
||||||
{
|
|
||||||
return LLUUID.Zero;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.m_inventoryService.CreateNewUserInventory(userProf.UUID);
|
|
||||||
Console.WriteLine("Created new inventory set for " + firstName + " " + lastName);
|
|
||||||
return userProf.UUID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class LocalSettings
|
public class LocalSettings
|
||||||
{
|
{
|
||||||
public string WelcomeMessage;
|
public string WelcomeMessage;
|
||||||
public bool AccountAuthentication = false;
|
public bool AccountAuthentication = false;
|
||||||
public string InventoryPlugin;
|
|
||||||
|
|
||||||
public LocalSettings(string welcomeMessage, bool accountsAuthenticate, string inventoryPlugin)
|
public LocalSettings(string welcomeMessage, bool accountsAuthenticate)
|
||||||
{
|
{
|
||||||
WelcomeMessage = welcomeMessage;
|
WelcomeMessage = welcomeMessage;
|
||||||
AccountAuthentication = accountsAuthenticate;
|
AccountAuthentication = accountsAuthenticate;
|
||||||
InventoryPlugin = inventoryPlugin;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,12 +41,12 @@ namespace SimpleApp
|
||||||
{
|
{
|
||||||
base.StartUp();
|
base.StartUp();
|
||||||
|
|
||||||
CommunicationsLocal.LocalSettings settings = new CommunicationsLocal.LocalSettings("", false, "");
|
CommunicationsLocal.LocalSettings settings = new CommunicationsLocal.LocalSettings("", false);
|
||||||
|
|
||||||
LocalInventoryService inventoryService = new LocalInventoryService();
|
LocalInventoryService inventoryService = new LocalInventoryService();
|
||||||
LocalUserServices userService = new LocalUserServices(m_networkServersInfo, m_networkServersInfo.DefaultHomeLocX, m_networkServersInfo.DefaultHomeLocY, inventoryService);
|
LocalUserServices userService = new LocalUserServices(m_networkServersInfo, m_networkServersInfo.DefaultHomeLocX, m_networkServersInfo.DefaultHomeLocY, inventoryService);
|
||||||
|
|
||||||
m_commsManager = new CommunicationsLocal(m_networkServersInfo, m_httpServer, m_assetCache, settings, userService );
|
m_commsManager = new CommunicationsLocal(m_networkServersInfo, m_httpServer, m_assetCache, settings, userService, inventoryService );
|
||||||
|
|
||||||
m_log.Notice(m_log.LineInfo);
|
m_log.Notice(m_log.LineInfo);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue