* Adding support for proper databased based user server. Not hooked up yet.
* Code cleaning.0.1-prestable
parent
b6487e4aaa
commit
4a155b08d7
|
@ -9,20 +9,20 @@ namespace OpenGrid.Framework.Data.DB4o
|
|||
{
|
||||
class DB4oGridData : IGridData
|
||||
{
|
||||
DB4oManager manager;
|
||||
DB4oGridManager manager;
|
||||
|
||||
public void Initialise() {
|
||||
manager = new DB4oManager("gridserver.yap");
|
||||
manager = new DB4oGridManager("gridserver.yap");
|
||||
}
|
||||
|
||||
public SimProfileData GetProfileByHandle(ulong handle) {
|
||||
lock (manager.profiles)
|
||||
lock (manager.simProfiles)
|
||||
{
|
||||
foreach (LLUUID UUID in manager.profiles.Keys)
|
||||
foreach (LLUUID UUID in manager.simProfiles.Keys)
|
||||
{
|
||||
if (manager.profiles[UUID].regionHandle == handle)
|
||||
if (manager.simProfiles[UUID].regionHandle == handle)
|
||||
{
|
||||
return manager.profiles[UUID];
|
||||
return manager.simProfiles[UUID];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,17 +31,17 @@ namespace OpenGrid.Framework.Data.DB4o
|
|||
|
||||
public SimProfileData GetProfileByLLUUID(LLUUID uuid)
|
||||
{
|
||||
lock (manager.profiles)
|
||||
lock (manager.simProfiles)
|
||||
{
|
||||
if (manager.profiles.ContainsKey(uuid))
|
||||
return manager.profiles[uuid];
|
||||
if (manager.simProfiles.ContainsKey(uuid))
|
||||
return manager.simProfiles[uuid];
|
||||
}
|
||||
throw new Exception("Unable to find profile with UUID (" + uuid.ToStringHyphenated() + ")");
|
||||
}
|
||||
|
||||
public DataResponse AddProfile(SimProfileData profile)
|
||||
{
|
||||
lock (manager.profiles)
|
||||
lock (manager.simProfiles)
|
||||
{
|
||||
if (manager.AddRow(profile))
|
||||
{
|
||||
|
@ -55,7 +55,7 @@ namespace OpenGrid.Framework.Data.DB4o
|
|||
}
|
||||
|
||||
public bool AuthenticateSim(LLUUID uuid, ulong handle, string key) {
|
||||
if (manager.profiles[uuid].regionRecvKey == key)
|
||||
if (manager.simProfiles[uuid].regionRecvKey == key)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -7,19 +7,19 @@ using libsecondlife;
|
|||
|
||||
namespace OpenGrid.Framework.Data.DB4o
|
||||
{
|
||||
class DB4oManager
|
||||
class DB4oGridManager
|
||||
{
|
||||
public Dictionary<LLUUID, SimProfileData> profiles = new Dictionary<LLUUID, SimProfileData>();
|
||||
public Dictionary<LLUUID, SimProfileData> simProfiles = new Dictionary<LLUUID, SimProfileData>();
|
||||
string dbfl;
|
||||
|
||||
public DB4oManager(string db4odb)
|
||||
public DB4oGridManager(string db4odb)
|
||||
{
|
||||
dbfl = db4odb;
|
||||
IObjectContainer database;
|
||||
database = Db4oFactory.OpenFile(dbfl);
|
||||
IObjectSet result = database.Get(typeof(SimProfileData));
|
||||
foreach(SimProfileData row in result) {
|
||||
profiles.Add(row.UUID, row);
|
||||
simProfiles.Add(row.UUID, row);
|
||||
}
|
||||
database.Close();
|
||||
}
|
||||
|
@ -31,13 +31,64 @@ namespace OpenGrid.Framework.Data.DB4o
|
|||
/// <returns>Successful?</returns>
|
||||
public bool AddRow(SimProfileData row)
|
||||
{
|
||||
if (profiles.ContainsKey(row.UUID))
|
||||
if (simProfiles.ContainsKey(row.UUID))
|
||||
{
|
||||
profiles[row.UUID] = row;
|
||||
simProfiles[row.UUID] = row;
|
||||
}
|
||||
else
|
||||
{
|
||||
profiles.Add(row.UUID, row);
|
||||
simProfiles.Add(row.UUID, row);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
IObjectContainer database;
|
||||
database = Db4oFactory.OpenFile(dbfl);
|
||||
database.Set(row);
|
||||
database.Close();
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
class DB4oGridManager
|
||||
{
|
||||
public Dictionary<LLUUID, UserProfileData> userProfiles = new Dictionary<LLUUID, UserProfileData>();
|
||||
string dbfl;
|
||||
|
||||
public DB4oGridManager(string db4odb)
|
||||
{
|
||||
dbfl = db4odb;
|
||||
IObjectContainer database;
|
||||
database = Db4oFactory.OpenFile(dbfl);
|
||||
IObjectSet result = database.Get(typeof(UserProfileData));
|
||||
foreach (UserProfileData row in result)
|
||||
{
|
||||
userProfiles.Add(row.UUID, row);
|
||||
}
|
||||
database.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a new profile to the database (Warning: Probably slow.)
|
||||
/// </summary>
|
||||
/// <param name="row">The profile to add</param>
|
||||
/// <returns>Successful?</returns>
|
||||
public bool AddRow(UserProfileData row)
|
||||
{
|
||||
if (userProfiles.ContainsKey(row.UUID))
|
||||
{
|
||||
userProfiles[row.UUID] = row;
|
||||
}
|
||||
else
|
||||
{
|
||||
userProfiles.Add(row.UUID, row);
|
||||
}
|
||||
|
||||
try
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenGrid.Framework.Data;
|
||||
using libsecondlife;
|
||||
|
||||
namespace OpenGrid.Framework.Data.DB4o
|
||||
{
|
||||
public class DB4oUserData : IUserData
|
||||
{
|
||||
public UserProfileData getUserByUUID(LLUUID uuid)
|
||||
{
|
||||
return new UserProfileData();
|
||||
}
|
||||
|
||||
public UserProfileData getUserByName(string name)
|
||||
{
|
||||
return getUserByName(name.Split(',')[0], name.Split(',')[1]);
|
||||
}
|
||||
|
||||
public UserProfileData getUserByName(string fname, string lname)
|
||||
{
|
||||
return new UserProfileData();
|
||||
}
|
||||
|
||||
public UserAgentData getAgentByUUID(LLUUID uuid)
|
||||
{
|
||||
return new UserAgentData();
|
||||
}
|
||||
|
||||
public UserAgentData getAgentByName(string name)
|
||||
{
|
||||
return getAgentByName(name.Split(',')[0], name.Split(',')[1]);
|
||||
}
|
||||
|
||||
public UserAgentData getAgentByName(string fname, string lname)
|
||||
{
|
||||
return new UserAgentData();
|
||||
}
|
||||
|
||||
public bool moneyTransferRequest(LLUUID from, LLUUID to, uint amount)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool inventoryTransferRequest(LLUUID from, LLUUID to, LLUUID item)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ProjectType>Local</ProjectType>
|
||||
<ProductVersion>8.0.50727</ProductVersion>
|
||||
|
@ -6,7 +6,8 @@
|
|||
<ProjectGuid>{39BD9497-0000-0000-0000-000000000000}</ProjectGuid>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ApplicationIcon></ApplicationIcon>
|
||||
<ApplicationIcon>
|
||||
</ApplicationIcon>
|
||||
<AssemblyKeyContainerName>
|
||||
</AssemblyKeyContainerName>
|
||||
<AssemblyName>OpenGrid.Framework.Data.DB4o</AssemblyName>
|
||||
|
@ -15,9 +16,11 @@
|
|||
<DefaultTargetSchema>IE50</DefaultTargetSchema>
|
||||
<DelaySign>false</DelaySign>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder></AppDesignerFolder>
|
||||
<AppDesignerFolder>
|
||||
</AppDesignerFolder>
|
||||
<RootNamespace>OpenGrid.Framework.Data.DB4o</RootNamespace>
|
||||
<StartupObject></StartupObject>
|
||||
<StartupObject>
|
||||
</StartupObject>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
</PropertyGroup>
|
||||
|
@ -28,7 +31,8 @@
|
|||
<ConfigurationOverrideFile>
|
||||
</ConfigurationOverrideFile>
|
||||
<DefineConstants>TRACE;DEBUG</DefineConstants>
|
||||
<DocumentationFile></DocumentationFile>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
<DebugSymbols>True</DebugSymbols>
|
||||
<FileAlignment>4096</FileAlignment>
|
||||
<Optimize>False</Optimize>
|
||||
|
@ -37,7 +41,8 @@
|
|||
<RemoveIntegerChecks>False</RemoveIntegerChecks>
|
||||
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<NoWarn></NoWarn>
|
||||
<NoWarn>
|
||||
</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
|
||||
|
@ -46,7 +51,8 @@
|
|||
<ConfigurationOverrideFile>
|
||||
</ConfigurationOverrideFile>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<DocumentationFile></DocumentationFile>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
<DebugSymbols>False</DebugSymbols>
|
||||
<FileAlignment>4096</FileAlignment>
|
||||
<Optimize>True</Optimize>
|
||||
|
@ -55,26 +61,27 @@
|
|||
<RemoveIntegerChecks>False</RemoveIntegerChecks>
|
||||
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<NoWarn></NoWarn>
|
||||
<NoWarn>
|
||||
</NoWarn>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" >
|
||||
<Reference Include="System">
|
||||
<HintPath>System.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml" >
|
||||
<Reference Include="System.Xml">
|
||||
<HintPath>System.Xml.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Data" >
|
||||
<Reference Include="System.Data">
|
||||
<HintPath>System.Data.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="libsecondlife.dll" >
|
||||
<Reference Include="libsecondlife.dll">
|
||||
<HintPath>..\bin\libsecondlife.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Db4objects.Db4o.dll" >
|
||||
<Reference Include="Db4objects.Db4o.dll">
|
||||
<HintPath>..\bin\Db4objects.Db4o.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
|
@ -84,7 +91,7 @@
|
|||
<Name>OpenGrid.Framework.Data</Name>
|
||||
<Project>{62CDF671-0000-0000-0000-000000000000}</Project>
|
||||
<Package>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Package>
|
||||
<Private>False</Private>
|
||||
<Private>False</Private>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -94,6 +101,7 @@
|
|||
<Compile Include="DB4oManager.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="DB4oUserData.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
|
@ -105,4 +113,4 @@
|
|||
<PostBuildEvent>
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
</Project>
|
|
@ -1,4 +1,4 @@
|
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ProjectType>Local</ProjectType>
|
||||
<ProductVersion>8.0.50727</ProductVersion>
|
||||
|
@ -6,7 +6,8 @@
|
|||
<ProjectGuid>{62CDF671-0000-0000-0000-000000000000}</ProjectGuid>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ApplicationIcon></ApplicationIcon>
|
||||
<ApplicationIcon>
|
||||
</ApplicationIcon>
|
||||
<AssemblyKeyContainerName>
|
||||
</AssemblyKeyContainerName>
|
||||
<AssemblyName>OpenGrid.Framework.Data</AssemblyName>
|
||||
|
@ -15,9 +16,11 @@
|
|||
<DefaultTargetSchema>IE50</DefaultTargetSchema>
|
||||
<DelaySign>false</DelaySign>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder></AppDesignerFolder>
|
||||
<AppDesignerFolder>
|
||||
</AppDesignerFolder>
|
||||
<RootNamespace>OpenGrid.Framework.Data</RootNamespace>
|
||||
<StartupObject></StartupObject>
|
||||
<StartupObject>
|
||||
</StartupObject>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
</PropertyGroup>
|
||||
|
@ -28,7 +31,8 @@
|
|||
<ConfigurationOverrideFile>
|
||||
</ConfigurationOverrideFile>
|
||||
<DefineConstants>TRACE;DEBUG</DefineConstants>
|
||||
<DocumentationFile></DocumentationFile>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
<DebugSymbols>True</DebugSymbols>
|
||||
<FileAlignment>4096</FileAlignment>
|
||||
<Optimize>False</Optimize>
|
||||
|
@ -37,7 +41,8 @@
|
|||
<RemoveIntegerChecks>False</RemoveIntegerChecks>
|
||||
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<NoWarn></NoWarn>
|
||||
<NoWarn>
|
||||
</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
|
||||
|
@ -46,7 +51,8 @@
|
|||
<ConfigurationOverrideFile>
|
||||
</ConfigurationOverrideFile>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<DocumentationFile></DocumentationFile>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
<DebugSymbols>False</DebugSymbols>
|
||||
<FileAlignment>4096</FileAlignment>
|
||||
<Optimize>True</Optimize>
|
||||
|
@ -55,22 +61,23 @@
|
|||
<RemoveIntegerChecks>False</RemoveIntegerChecks>
|
||||
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<NoWarn></NoWarn>
|
||||
<NoWarn>
|
||||
</NoWarn>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" >
|
||||
<Reference Include="System">
|
||||
<HintPath>System.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml" >
|
||||
<Reference Include="System.Xml">
|
||||
<HintPath>System.Xml.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Data" >
|
||||
<Reference Include="System.Data">
|
||||
<HintPath>System.Data.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="libsecondlife.dll" >
|
||||
<Reference Include="libsecondlife.dll">
|
||||
<HintPath>..\bin\libsecondlife.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
|
@ -84,6 +91,7 @@
|
|||
<Compile Include="SimProfileData.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="UserData.cs" />
|
||||
<Compile Include="UserProfileData.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
|
@ -98,4 +106,4 @@
|
|||
<PostBuildEvent>
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
</Project>
|
|
@ -0,0 +1,24 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using libsecondlife;
|
||||
|
||||
namespace OpenGrid.Framework.Data
|
||||
{
|
||||
public interface IUserData
|
||||
{
|
||||
// Retrieval
|
||||
// User Profiles
|
||||
UserProfileData getUserByUUID(LLUUID user);
|
||||
UserProfileData getUserByName(string name);
|
||||
UserProfileData getUserByName(string fname, string lname);
|
||||
// User Agents
|
||||
UserAgentData getAgentByUUID(LLUUID user);
|
||||
UserAgentData getAgentByName(string name);
|
||||
UserAgentData getAgentByName(string fname, string lname);
|
||||
|
||||
// Transactional
|
||||
bool moneyTransferRequest(LLUUID from, LLUUID to, uint amount);
|
||||
bool inventoryTransferRequest(LLUUID from, LLUUID to, LLUUID inventory);
|
||||
}
|
||||
}
|
|
@ -10,6 +10,8 @@ namespace OpenGrid.Framework.Data
|
|||
string username; // The configurable part of the users username
|
||||
string surname; // The users surname (can be used to indicate user class - eg 'Test User' or 'Test Admin')
|
||||
|
||||
string passwordHash; // Hash of the users password
|
||||
|
||||
ulong homeRegion; // RegionHandle of home
|
||||
LLVector3 homeLocation; // Home Location inside the sim
|
||||
|
||||
|
@ -27,7 +29,19 @@ namespace OpenGrid.Framework.Data
|
|||
|
||||
LLUUID profileImage; // My avatars profile image
|
||||
LLUUID profileFirstImage; // First-life image
|
||||
UserAgentData currentAgent; // The users last agent
|
||||
}
|
||||
|
||||
public class UserAgentData
|
||||
{
|
||||
public string agentIP; // The IP of the agent
|
||||
public uint agentPort; // The port of the agent
|
||||
public bool agentOnline; // The online status of the agent
|
||||
public LLUUID sessionID; // The session ID for the agent
|
||||
public LLUUID secureSessionID; // The secure session ID for the agent
|
||||
public LLUUID regionID; // The region ID the agent occupies
|
||||
public uint loginTime; // EPOCH based Timestamp
|
||||
public uint logoutTime; // Timestamp or 0 if N/A
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue