2007-05-05 21:49:24 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Text;
|
|
|
|
using OpenGrid.Framework.Data;
|
|
|
|
using libsecondlife;
|
|
|
|
|
|
|
|
|
|
|
|
namespace OpenGrid.Framework.Data.DB4o
|
|
|
|
{
|
|
|
|
class DB4oGridData : IGridData
|
|
|
|
{
|
2007-05-07 16:32:30 +00:00
|
|
|
DB4oGridManager manager;
|
2007-05-05 21:49:24 +00:00
|
|
|
|
|
|
|
public void Initialise() {
|
2007-05-07 16:32:30 +00:00
|
|
|
manager = new DB4oGridManager("gridserver.yap");
|
2007-05-05 21:49:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public SimProfileData GetProfileByHandle(ulong handle) {
|
2007-05-07 16:32:30 +00:00
|
|
|
lock (manager.simProfiles)
|
2007-05-05 21:49:24 +00:00
|
|
|
{
|
2007-05-07 16:32:30 +00:00
|
|
|
foreach (LLUUID UUID in manager.simProfiles.Keys)
|
2007-05-05 21:49:24 +00:00
|
|
|
{
|
2007-05-07 16:32:30 +00:00
|
|
|
if (manager.simProfiles[UUID].regionHandle == handle)
|
2007-05-05 21:49:24 +00:00
|
|
|
{
|
2007-05-07 16:32:30 +00:00
|
|
|
return manager.simProfiles[UUID];
|
2007-05-05 21:49:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
throw new Exception("Unable to find profile with handle (" + handle.ToString() + ")");
|
|
|
|
}
|
|
|
|
|
|
|
|
public SimProfileData GetProfileByLLUUID(LLUUID uuid)
|
|
|
|
{
|
2007-05-07 16:32:30 +00:00
|
|
|
lock (manager.simProfiles)
|
2007-05-05 21:49:24 +00:00
|
|
|
{
|
2007-05-07 16:32:30 +00:00
|
|
|
if (manager.simProfiles.ContainsKey(uuid))
|
|
|
|
return manager.simProfiles[uuid];
|
2007-05-05 21:49:24 +00:00
|
|
|
}
|
|
|
|
throw new Exception("Unable to find profile with UUID (" + uuid.ToStringHyphenated() + ")");
|
|
|
|
}
|
|
|
|
|
2007-05-05 23:04:47 +00:00
|
|
|
public DataResponse AddProfile(SimProfileData profile)
|
|
|
|
{
|
2007-05-07 16:32:30 +00:00
|
|
|
lock (manager.simProfiles)
|
2007-05-05 23:57:43 +00:00
|
|
|
{
|
2007-05-06 01:43:12 +00:00
|
|
|
if (manager.AddRow(profile))
|
|
|
|
{
|
|
|
|
return DataResponse.RESPONSE_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return DataResponse.RESPONSE_ERROR;
|
|
|
|
}
|
2007-05-05 23:57:43 +00:00
|
|
|
}
|
2007-05-05 23:04:47 +00:00
|
|
|
}
|
|
|
|
|
2007-05-05 21:49:24 +00:00
|
|
|
public bool AuthenticateSim(LLUUID uuid, ulong handle, string key) {
|
2007-05-07 16:32:30 +00:00
|
|
|
if (manager.simProfiles[uuid].regionRecvKey == key)
|
2007-05-05 21:49:24 +00:00
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Close()
|
|
|
|
{
|
|
|
|
manager = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public string getName()
|
|
|
|
{
|
|
|
|
return "DB4o Grid Provider";
|
|
|
|
}
|
|
|
|
|
|
|
|
public string getVersion()
|
|
|
|
{
|
|
|
|
return "0.1";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|