Begining major rework of Asset/Inventory code. Doing a lot of refectoing. What's in here so far?
+ Inventory, Asset and Image managers are now directly apart of the SecondLife class + Root Inventory folder has been added to MainAvatar and is set upon login + Inventory is no longer downloaded all at once, you have to request the download of individual folders + Folder downloading is available Asynchronously, and returns a object that has a ManualResetEvent that you can use to optionally block with + The code for AssetManager has been reworked some in prep for allowing Wearables to be Saved/Loaded to/from disk, and for creating new wearables. git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@742 52acb1d6-8a22-11de-b505-999d5b087335
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
using libsecondlife;
|
||||
using libsecondlife.InventorySystem;
|
||||
@@ -38,10 +39,8 @@ namespace IA_SimpleInventory
|
||||
/// </summary>
|
||||
public class SimpleInventory
|
||||
{
|
||||
protected SecondLife client;
|
||||
protected InventoryManager AgentInventory;
|
||||
|
||||
protected bool DownloadInventoryOnConnect = true;
|
||||
private SecondLife client;
|
||||
private ManualResetEvent ConnectedSignal = new ManualResetEvent(false);
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
@@ -53,9 +52,14 @@ namespace IA_SimpleInventory
|
||||
}
|
||||
|
||||
SimpleInventory simple = new SimpleInventory();
|
||||
simple.Connect(args[0], args[1], args[2]);
|
||||
simple.doStuff();
|
||||
simple.Disconnect();
|
||||
if (simple.Connect(args[0], args[1], args[2]))
|
||||
{
|
||||
if (simple.ConnectedSignal.WaitOne(TimeSpan.FromMinutes(1), false))
|
||||
{
|
||||
simple.doStuff();
|
||||
simple.Disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected SimpleInventory()
|
||||
@@ -63,6 +67,7 @@ namespace IA_SimpleInventory
|
||||
try
|
||||
{
|
||||
client = new SecondLife();
|
||||
client.Network.OnConnected += new NetworkManager.ConnectedCallback(Network_OnConnected);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -72,6 +77,11 @@ namespace IA_SimpleInventory
|
||||
}
|
||||
}
|
||||
|
||||
void Network_OnConnected(object sender)
|
||||
{
|
||||
ConnectedSignal.Set();
|
||||
}
|
||||
|
||||
protected bool Connect(string FirstName, string LastName, string Password)
|
||||
{
|
||||
Console.WriteLine("Attempting to connect and login to SecondLife.");
|
||||
@@ -80,7 +90,7 @@ namespace IA_SimpleInventory
|
||||
Dictionary<string, object> loginReply = new Dictionary<string, object>();
|
||||
|
||||
// Login
|
||||
if (!client.Network.Login(FirstName, LastName, Password, "createnotecard", "static.sprocket@gmail.com"))
|
||||
if (!client.Network.Login(FirstName, LastName, Password, "IA_SimpleInventory", "static.sprocket@gmail.com"))
|
||||
{
|
||||
// Login failed
|
||||
Console.WriteLine("Error logging in: " + client.Network.LoginError);
|
||||
@@ -92,22 +102,6 @@ namespace IA_SimpleInventory
|
||||
Console.WriteLine("AgentID: " + client.Network.AgentID);
|
||||
Console.WriteLine("SessionID: " + client.Network.SessionID);
|
||||
|
||||
// Get Root Inventory Folder UUID
|
||||
Console.WriteLine("Pulling root folder UUID from login data.");
|
||||
ArrayList alInventoryRoot = (ArrayList)client.Network.LoginValues["inventory-root"];
|
||||
Hashtable htInventoryRoot = (Hashtable)alInventoryRoot[0];
|
||||
LLUUID agentRootFolderID = new LLUUID((string)htInventoryRoot["folder_id"]);
|
||||
|
||||
// Initialize Inventory Manager object
|
||||
Console.WriteLine("Initializing Inventory Manager.");
|
||||
AgentInventory = new InventoryManager(client, agentRootFolderID);
|
||||
|
||||
if (DownloadInventoryOnConnect)
|
||||
{
|
||||
// and request an inventory download
|
||||
Console.WriteLine("Downloading Inventory.");
|
||||
AgentInventory.DownloadInventory();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -120,17 +114,19 @@ namespace IA_SimpleInventory
|
||||
|
||||
protected void doStuff()
|
||||
{
|
||||
// and request an inventory download
|
||||
Console.WriteLine("Downloading Inventory.");
|
||||
client.Inventory.DownloadInventory();
|
||||
|
||||
|
||||
Console.WriteLine("Dumping a copy of " + client.Self.FirstName + "'s inventory to the console.");
|
||||
Console.WriteLine();
|
||||
|
||||
if (AgentInventory != null)
|
||||
{
|
||||
InventoryFolder root = AgentInventory.getRootFolder();
|
||||
InventoryFolder root = client.Inventory.getRootFolder();
|
||||
|
||||
if (root != null)
|
||||
{
|
||||
Console.WriteLine(root.toXML(false));
|
||||
}
|
||||
if (root != null)
|
||||
{
|
||||
Console.WriteLine(root.toXML(false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user