Initial working Grid Inventory server. Only been tested on a very small grid, so likely to have problems on a larger grid with more people?

To use , both the user server and Inventory server need to be running this latest revision. (older regions should be able to still be used, just the user won't have inventory on them). Also and HERE IS THE BIG BREAK ISSUE, currently, so that the initial inventory details for a user are added to the inventory db , you need to recreate the accounts using the user server "create user" feature. It should be quite easy to manual populate the inventory database instead but I someone else will need to look into that) Also I've only tested using SQLite as the database provider, there is a Mysql inventory provider but I don't know if it works (SQLite is set as default, so you will need to change it in the inventory server config.xml)
afrisby
MW 2007-12-01 18:49:17 +00:00
parent fff468dcfe
commit 5df851761a
15 changed files with 430 additions and 27 deletions

View File

@ -39,7 +39,7 @@ namespace OpenSim.Framework.Communications
public interface IInventoryServices public interface IInventoryServices
{ {
void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack); void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack);
void AddNewInventoryFolder(LLUUID userID, InventoryFolderImpl folder); void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder);
void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); void AddNewInventoryItem(LLUUID userID, InventoryItemBase item);
void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); void DeleteInventoryItem(LLUUID userID, InventoryItemBase item);
void CreateNewUserInventory(LLUUID user); void CreateNewUserInventory(LLUUID user);

View File

@ -150,7 +150,7 @@ namespace OpenSim.Framework.Communications
} }
} }
public void deleteItem(InventoryItemBase item) public void DeleteItem(InventoryItemBase item)
{ {
foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins)
{ {
@ -231,7 +231,7 @@ namespace OpenSim.Framework.Communications
public abstract void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, public abstract void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack,
InventoryItemInfo itemCallBack); InventoryItemInfo itemCallBack);
public abstract void AddNewInventoryFolder(LLUUID userID, InventoryFolderImpl folder); public abstract void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder);
public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item);
public abstract void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); public abstract void DeleteInventoryItem(LLUUID userID, InventoryItemBase item);
} }

View File

@ -366,7 +366,7 @@ namespace OpenSim.Framework.UserManagement
/// ///
/// </summary> /// </summary>
/// <param name="user"></param> /// <param name="user"></param>
public void AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY) public LLUUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY)
{ {
UserProfileData user = new UserProfileData(); UserProfileData user = new UserProfileData();
user.homeLocation = new LLVector3(128, 128, 100); user.homeLocation = new LLVector3(128, 128, 100);
@ -391,6 +391,8 @@ namespace OpenSim.Framework.UserManagement
MainLog.Instance.Verbose("Unable to add user via " + plugin.Key + "(" + e.ToString() + ")"); MainLog.Instance.Verbose("Unable to add user via " + plugin.Key + "(" + e.ToString() + ")");
} }
} }
return user.UUID;
} }
public abstract UserProfileData SetupMasterUser(string firstName, string lastName); public abstract UserProfileData SetupMasterUser(string firstName, string lastName);

View File

@ -46,6 +46,6 @@ namespace OpenSim.Framework
/// ///
/// </summary> /// </summary>
/// <param name="user"></param> /// <param name="user"></param>
void AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY); LLUUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY);
} }
} }

View File

@ -38,7 +38,7 @@ namespace OpenSim.Framework
configMember.addConfigurationOption("user_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, configMember.addConfigurationOption("user_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
"Key to expect from user server", "null", false); "Key to expect from user server", "null", false);
configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING, configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
"DLL for database provider", "OpenSim.Framework.Data.MySQL.dll", false); "DLL for database provider", "OpenSim.Framework.Data.SQLite.dll", false);
configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_INT32, configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
"Http Listener port", DefaultHttpPort.ToString(), false); "Http Listener port", DefaultHttpPort.ToString(), false);
} }

View File

@ -245,6 +245,25 @@ namespace OpenSim.Framework
void deleteInventoryFolder(LLUUID folder); void deleteInventoryFolder(LLUUID folder);
} }
public class InventoryCollection
{
public List<InventoryFolderBase> Folders;
public List<InventoryItemBase> AllItems;
public LLUUID UserID;
public InventoryCollection()
{
Folders = new List<InventoryFolderBase>();
AllItems = new List<InventoryItemBase>();
}
public InventoryCollection(List<InventoryFolderBase> folders, List<InventoryItemBase> allItems)
{
Folders = folders;
AllItems = allItems;
}
}
/* /*
* .Net has some issues, serializing a dictionary, so we cannot reuse the InventoryFolder * .Net has some issues, serializing a dictionary, so we cannot reuse the InventoryFolder
* class defined in Communications.Framework.Communications.Caches. So we serialize/deserialize * class defined in Communications.Framework.Communications.Caches. So we serialize/deserialize

View File

@ -8,8 +8,11 @@ using System.Xml.Serialization;
namespace OpenSim.Framework.Servers namespace OpenSim.Framework.Servers
{ {
public delegate void ReturnResponse<T>(T reponse);
public class RestObjectPoster public class RestObjectPoster
{ {
public static void BeginPostObject<TRequest>(string requestUrl, TRequest obj) public static void BeginPostObject<TRequest>(string requestUrl, TRequest obj)
{ {
Type type = typeof(TRequest); Type type = typeof(TRequest);
@ -46,4 +49,93 @@ namespace OpenSim.Framework.Servers
} }
} }
} }
public class RestObjectPosterResponse<TResponse>
{
public ReturnResponse<TResponse> ReturnResponseVal;
public void BeginPostObject<TRequest>(string requestUrl, TRequest obj)
{
Type type = typeof(TRequest);
WebRequest request = WebRequest.Create(requestUrl);
request.Method = "POST";
request.ContentType = "text/xml";
MemoryStream buffer = new MemoryStream();
XmlWriterSettings settings = new XmlWriterSettings();
settings.Encoding = Encoding.UTF8;
using (XmlWriter writer = XmlWriter.Create(buffer, settings))
{
XmlSerializer serializer = new XmlSerializer(type);
serializer.Serialize(writer, obj);
writer.Flush();
}
int length = (int)buffer.Length;
request.ContentLength = length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(buffer.ToArray(), 0, length);
IAsyncResult result = request.BeginGetResponse(AsyncCallback, request);
}
private void AsyncCallback(IAsyncResult result)
{
WebRequest request = (WebRequest)result.AsyncState;
using (WebResponse resp = request.EndGetResponse(result))
{
TResponse deserial;
XmlSerializer deserializer = new XmlSerializer(typeof(TResponse));
deserial = (TResponse)deserializer.Deserialize(resp.GetResponseStream());
if (deserial != null && ReturnResponseVal != null)
{
ReturnResponseVal(deserial);
}
}
}
}
public class SyncRestObjectPoster
{
public static TResponse BeginPostObject<TRequest, TResponse>(string requestUrl, TRequest obj)
{
Type type = typeof(TRequest);
WebRequest request = WebRequest.Create(requestUrl);
request.Method = "POST";
request.ContentType = "text/xml";
MemoryStream buffer = new MemoryStream();
XmlWriterSettings settings = new XmlWriterSettings();
settings.Encoding = Encoding.UTF8;
using (XmlWriter writer = XmlWriter.Create(buffer, settings))
{
XmlSerializer serializer = new XmlSerializer(type);
serializer.Serialize(writer, obj);
writer.Flush();
}
int length = (int)buffer.Length;
request.ContentLength = length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(buffer.ToArray(), 0, length);
TResponse deserial = default(TResponse);
using (WebResponse resp = request.GetResponse())
{
XmlSerializer deserializer = new XmlSerializer(typeof(TResponse));
deserial = (TResponse)deserializer.Deserialize(resp.GetResponseStream());
}
return deserial;
}
}
} }

View File

@ -38,6 +38,8 @@ namespace OpenSim.Framework
public string GridSendKey = ""; public string GridSendKey = "";
public string GridRecvKey = ""; public string GridRecvKey = "";
public string InventoryUrl = "";
public string DatabaseProvider = ""; public string DatabaseProvider = "";
public static uint DefaultHttpPort = 8002; public static uint DefaultHttpPort = 8002;
@ -68,6 +70,11 @@ namespace OpenSim.Framework
"Key to send to grid server", "null", false); "Key to send to grid server", "null", false);
configMember.addConfigurationOption("grid_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, configMember.addConfigurationOption("grid_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
"Key to expect from grid server", "null", false); "Key to expect from grid server", "null", false);
configMember.addConfigurationOption("default_inventory_server",
ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
"Default Inventory Server URI",
"http://127.0.0.1:8004/", false);
configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING, configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING,
"DLL for database provider", "OpenSim.Framework.Data.MySQL.dll", false); "DLL for database provider", "OpenSim.Framework.Data.MySQL.dll", false);
@ -95,6 +102,9 @@ namespace OpenSim.Framework
case "grid_recv_key": case "grid_recv_key":
GridRecvKey = (string) configuration_result; GridRecvKey = (string) configuration_result;
break; break;
case "default_inventory_server":
InventoryUrl = (string)configuration_result;
break;
case "database_provider": case "database_provider":
DatabaseProvider = (string) configuration_result; DatabaseProvider = (string) configuration_result;
break; break;

View File

@ -0,0 +1,104 @@
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
using libsecondlife;
namespace OpenSim.Grid.InventoryServer
{
public class GridInventoryService : InventoryServiceBase
{
public override void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack,
InventoryItemInfo itemCallBack)
{
}
private bool TryGetUsersInventory(LLUUID userID, out List<InventoryFolderBase> folderList, out List<InventoryItemBase> itemsList)
{
List<InventoryFolderBase> folders = RequestFirstLevelFolders(userID);
List<InventoryItemBase> allItems = new List<InventoryItemBase>();
if (folders != null)
{
foreach (InventoryFolderBase folder in folders)
{
if (folder.parentID != LLUUID.Zero)
{
List<InventoryItemBase> items = RequestFolderItems(folder.folderID);
if (items != null)
{
allItems.InsertRange(0, items);
}
}
}
}
folderList = folders;
itemsList = allItems;
if (folderList != null)
{
return true;
}
else
{
return false;
}
}
public InventoryCollection GetUserInventory(LLUUID userID)
{
InventoryCollection invCollection = new InventoryCollection();
List<InventoryFolderBase> folders;
List<InventoryItemBase> allItems;
if (TryGetUsersInventory(userID, out folders, out allItems))
{
invCollection.AllItems = allItems;
invCollection.Folders = folders;
invCollection.UserID = userID;
}
return invCollection;
}
public bool CreateUsersInventory(LLUUID user)
{
CreateNewUserInventory(user);
return true;
}
public override void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder)
{
AddFolder(folder);
}
public override void AddNewInventoryItem(LLUUID userID, InventoryItemBase item)
{
AddItem(item);
}
public bool AddInventoryFolder( InventoryFolderBase folder)
{
AddNewInventoryFolder(folder.agentID, folder);
return true;
}
public bool AddInventoryItem( InventoryItemBase item)
{
AddNewInventoryItem(item.avatarID, item);
return true;
}
public override void DeleteInventoryItem(LLUUID userID, InventoryItemBase item)
{
DeleteItem(item);
}
public bool DeleteInvItem( InventoryItemBase item)
{
DeleteInventoryItem(item.avatarID, item);
return true;
}
}
}

View File

@ -47,6 +47,7 @@ namespace OpenSim.Grid.InventoryServer
LogBase m_console; LogBase m_console;
InventoryManager m_inventoryManager; InventoryManager m_inventoryManager;
InventoryConfig m_config; InventoryConfig m_config;
GridInventoryService m_inventoryService;
public const string LogName = "INVENTORY"; public const string LogName = "INVENTORY";
@ -69,13 +70,35 @@ namespace OpenSim.Grid.InventoryServer
{ {
MainLog.Instance.Notice("Initialising inventory manager..."); MainLog.Instance.Notice("Initialising inventory manager...");
m_config = new InventoryConfig(LogName, (Path.Combine(Util.configDir(), "InventoryServer_Config.xml"))); m_config = new InventoryConfig(LogName, (Path.Combine(Util.configDir(), "InventoryServer_Config.xml")));
m_inventoryManager = new InventoryManager(); m_inventoryService = new GridInventoryService();
m_inventoryManager.AddDatabasePlugin(m_config.DatabaseProvider); // m_inventoryManager = new InventoryManager();
m_inventoryService.AddPlugin(m_config.DatabaseProvider);
MainLog.Instance.Notice(LogName, "Starting HTTP server ..."); MainLog.Instance.Notice(LogName, "Starting HTTP server ...");
BaseHttpServer httpServer = new BaseHttpServer(m_config.HttpPort); BaseHttpServer httpServer = new BaseHttpServer(m_config.HttpPort);
httpServer.AddStreamHandler(
new RestDeserialisehandler<LLUUID, InventoryCollection>("POST", "/GetInventory/",
m_inventoryService.GetUserInventory));
httpServer.AddStreamHandler(
new RestDeserialisehandler<LLUUID, bool>("POST", "/CreateInventory/",
m_inventoryService.CreateUsersInventory));
httpServer.AddStreamHandler(
new RestDeserialisehandler<InventoryFolderBase, bool>("POST", "/NewFolder/",
m_inventoryService.AddInventoryFolder));
httpServer.AddStreamHandler(new InventoryManager.GetInventory(m_inventoryManager)); httpServer.AddStreamHandler(
new RestDeserialisehandler<InventoryItemBase, bool>("POST", "/NewItem/",
m_inventoryService.AddInventoryItem));
httpServer.AddStreamHandler(
new RestDeserialisehandler<InventoryItemBase, bool>("POST", "/DeleteItem/",
m_inventoryService.DeleteInvItem));
httpServer.AddStreamHandler(
new RestDeserialisehandler<LLUUID, List<InventoryFolderBase>>("POST", "/RootFolders/",
m_inventoryService.RequestFirstLevelFolders));
// httpServer.AddStreamHandler(new InventoryManager.GetInventory(m_inventoryManager));
httpServer.Start(); httpServer.Start();
MainLog.Instance.Notice(LogName, "Started HTTP server"); MainLog.Instance.Notice(LogName, "Started HTTP server");
@ -96,6 +119,9 @@ namespace OpenSim.Grid.InventoryServer
switch (cmd) switch (cmd)
{ {
case "quit": case "quit":
case "add-user":
m_inventoryService.CreateUsersInventory(LLUUID.Random());
break;
case "shutdown": case "shutdown":
m_console.Close(); m_console.Close();
Environment.Exit(0); Environment.Exit(0);

View File

@ -27,7 +27,9 @@
*/ */
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using libsecondlife;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Console; using OpenSim.Framework.Console;
using OpenSim.Framework.Servers; using OpenSim.Framework.Servers;
@ -44,6 +46,7 @@ namespace OpenSim.Grid.UserServer
public UserLoginService m_loginService; public UserLoginService m_loginService;
private LogBase m_console; private LogBase m_console;
private LLUUID m_lastCreatedUser = LLUUID.Random();
[STAThread] [STAThread]
public static void Main(string[] args) public static void Main(string[] args)
@ -123,7 +126,9 @@ namespace OpenSim.Grid.UserServer
tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + ""); tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + "");
m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY); LLUUID userID = m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY);
RestObjectPoster.BeginPostObject<LLUUID>(m_userManager._config.InventoryUrl + "CreateInventory/", userID);
m_lastCreatedUser = userID;
break; break;
} }
} }
@ -145,9 +150,21 @@ namespace OpenSim.Grid.UserServer
m_console.Close(); m_console.Close();
Environment.Exit(0); Environment.Exit(0);
break; break;
case "test-inventory":
// RestObjectPosterResponse<List<InventoryFolderBase>> requester = new RestObjectPosterResponse<List<InventoryFolderBase>>();
// requester.ReturnResponseVal = TestResponse;
// requester.BeginPostObject<LLUUID>(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser);
List<InventoryFolderBase> folders = SyncRestObjectPoster.BeginPostObject<LLUUID, List<InventoryFolderBase>>(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser);
break;
} }
} }
public void TestResponse(List<InventoryFolderBase> resp)
{
System.Console.WriteLine("response got");
}
/*private void ConfigDB(IGenericConfig configData) /*private void ConfigDB(IGenericConfig configData)
{ {
try try

View File

@ -28,12 +28,16 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic;
using System.Net; using System.Net;
using Nwc.XmlRpc; using Nwc.XmlRpc;
using libsecondlife;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Console; using OpenSim.Framework.Console;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Data; using OpenSim.Framework.Data;
using OpenSim.Framework.UserManagement; using OpenSim.Framework.UserManagement;
using InventoryFolder = OpenSim.Framework.InventoryFolder;
namespace OpenSim.Grid.UserServer namespace OpenSim.Grid.UserServer
{ {
@ -189,5 +193,51 @@ namespace OpenSim.Grid.UserServer
} }
} }
protected override InventoryData CreateInventoryData(LLUUID userID)
{
List<InventoryFolderBase> folders = SyncRestObjectPoster.BeginPostObject<LLUUID, List<InventoryFolderBase>>(m_config.InventoryUrl + "RootFolders/", userID);
if (folders.Count > 0)
{
LLUUID rootID = LLUUID.Zero;
ArrayList AgentInventoryArray = new ArrayList();
Hashtable TempHash;
foreach (InventoryFolderBase InvFolder in folders)
{
if (InvFolder.parentID == LLUUID.Zero)
{
rootID = InvFolder.folderID;
}
TempHash = new Hashtable();
TempHash["name"] = InvFolder.name;
TempHash["parent_id"] = InvFolder.parentID.ToStringHyphenated();
TempHash["version"] = (Int32)InvFolder.version;
TempHash["type_default"] = (Int32)InvFolder.type;
TempHash["folder_id"] = InvFolder.folderID.ToStringHyphenated();
AgentInventoryArray.Add(TempHash);
}
return new InventoryData(AgentInventoryArray, rootID);
}
else
{
AgentInventory userInventory = new AgentInventory();
userInventory.CreateRootFolder(userID, false);
ArrayList AgentInventoryArray = new ArrayList();
Hashtable TempHash;
foreach (InventoryFolder InvFolder in userInventory.InventoryFolders.Values)
{
TempHash = new Hashtable();
TempHash["name"] = InvFolder.FolderName;
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

@ -76,7 +76,7 @@ namespace OpenSim.Region.Communications.Local
} }
} }
public override void AddNewInventoryFolder(LLUUID userID, InventoryFolderImpl folder) public override void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder)
{ {
AddFolder(folder); AddFolder(folder);
} }
@ -88,7 +88,7 @@ namespace OpenSim.Region.Communications.Local
public override void DeleteInventoryItem(LLUUID userID, InventoryItemBase item) public override void DeleteInventoryItem(LLUUID userID, InventoryItemBase item)
{ {
deleteItem(item); DeleteItem(item);
} }
} }
} }

View File

@ -25,9 +25,11 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
*/ */
using System;
using System.Collections.Generic; using System.Collections.Generic;
using libsecondlife; using libsecondlife;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Communications; using OpenSim.Framework.Communications;
using OpenSim.Framework.Communications.Cache; using OpenSim.Framework.Communications.Cache;
@ -36,6 +38,7 @@ namespace OpenSim.Region.Communications.OGS1
public class OGS1InventoryService : IInventoryServices public class OGS1InventoryService : IInventoryServices
{ {
private string _inventoryServerUrl; private string _inventoryServerUrl;
private Dictionary<LLUUID, InventoryRequest> m_RequestingInventory = new Dictionary<LLUUID, InventoryRequest>();
public OGS1InventoryService(string inventoryServerUrl) public OGS1InventoryService(string inventoryServerUrl)
{ {
@ -47,31 +50,96 @@ namespace OpenSim.Region.Communications.OGS1
public void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, public void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack,
InventoryItemInfo itemCallBack) InventoryItemInfo itemCallBack)
{ {
//TODO! Uncomment when all is done
//SerializableInventory userInventory = null;
//RestClient inventoryServer = new RestClient(_inventoryServerUrl); if (!m_RequestingInventory.ContainsKey(userID))
//inventoryServer.AddResourcePath("inventory"); {
//inventoryServer.AddResourcePath("user"); InventoryRequest request = new InventoryRequest(userID, folderCallBack, itemCallBack);
//inventoryServer.AddResourcePath(userID.ToStringHyphenated()); m_RequestingInventory.Add(userID, request);
RequestInventory(userID);
//using (Stream userInventoryStream = inventoryServer.Request()) }
//{
// XmlSerializer x = new XmlSerializer(typeof(SerializableInventory));
// userInventory = (SerializableInventory)x.Deserialize(userInventoryStream);
//}
} }
public void AddNewInventoryFolder(LLUUID userID, InventoryFolderImpl folder) private void RequestInventory(LLUUID userID)
{ {
try
{
RestObjectPosterResponse<InventoryCollection> requester = new RestObjectPosterResponse<InventoryCollection>();
requester.ReturnResponseVal = InventoryResponse;
requester.BeginPostObject<LLUUID>(_inventoryServerUrl + "/GetInventory/", userID);
}
catch (Exception)
{
}
}
private void InventoryResponse(InventoryCollection response)
{
LLUUID userID = response.UserID;
if (m_RequestingInventory.ContainsKey(userID))
{
InventoryFolderImpl rootFolder = null;
InventoryRequest request = m_RequestingInventory[userID];
foreach (InventoryFolderBase folder in response.Folders)
{
if (folder.parentID == LLUUID.Zero)
{
InventoryFolderImpl newfolder = new InventoryFolderImpl(folder);
rootFolder = newfolder;
request.FolderCallBack(userID, newfolder);
}
}
if (rootFolder != null)
{
foreach (InventoryFolderBase folder in response.Folders)
{
if (folder.folderID != rootFolder.folderID)
{
InventoryFolderImpl newfolder = new InventoryFolderImpl(folder);
request.FolderCallBack(userID, newfolder);
}
}
foreach (InventoryItemBase item in response.AllItems)
{
request.ItemCallBack(userID, item);
}
}
}
}
public void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder)
{
try
{
RestObjectPoster.BeginPostObject<InventoryFolderBase>(_inventoryServerUrl + "/NewFolder/", folder);
}
catch (Exception)
{
}
} }
public void AddNewInventoryItem(LLUUID userID, InventoryItemBase item) public void AddNewInventoryItem(LLUUID userID, InventoryItemBase item)
{ {
try
{
RestObjectPoster.BeginPostObject<InventoryItemBase>(_inventoryServerUrl + "/NewItem/", item);
}
catch (Exception)
{
}
} }
public void DeleteInventoryItem(LLUUID userID, InventoryItemBase item) public void DeleteInventoryItem(LLUUID userID, InventoryItemBase item)
{ {
try
{
RestObjectPoster.BeginPostObject<InventoryItemBase>(_inventoryServerUrl + "/DeleteItem/", item);
}
catch (Exception)
{
}
} }
public void CreateNewUserInventory(LLUUID user) public void CreateNewUserInventory(LLUUID user)
@ -84,5 +152,19 @@ namespace OpenSim.Region.Communications.OGS1
} }
#endregion #endregion
public class InventoryRequest
{
public LLUUID UserID;
public InventoryFolderInfo FolderCallBack;
public InventoryItemInfo ItemCallBack;
public InventoryRequest(LLUUID userId, InventoryFolderInfo folderCall, InventoryItemInfo itemCall)
{
UserID = userId;
FolderCallBack = folderCall;
ItemCallBack = itemCall;
}
}
} }
} }

View File

@ -162,9 +162,10 @@ namespace OpenSim.Region.Communications.OGS1
return data; return data;
} }
public void AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY) public LLUUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY)
{ {
throw new Exception("The method or operation is not implemented."); throw new Exception("The method or operation is not implemented.");
return LLUUID.Zero;
} }
} }
} }