Files
libremetaverse/Programs/Simian/Extensions/AccountManager.cs
John Hurliman abf0c15384 [Simian]
* Completed a partial port of OpenSim's LSL API. Thank you to everyone on the OpenSim team for their hard work on this incredibly large feature
* Added Agent.GetSimulatorPosition()
* Corrected default PrimFlags for agents and prims
* Stubs for encoding/decoding prim linkset assets
* Route chat through the scene
* Stub for grid messaging (IM and email)
* Add GetTerrainHeightAt(), removed duplicate heightmap storage in Movement.cs
* Added a permissions manager stub
* Store wind speeds, added functions to get wind speed
* Make sure all of the important prim properties are set before creating an object
* Lots of new object manipulation functions in scene
* Properly clean up event queues on agent exit
* Stubbed out a space for a scripting engine
* Stubbed out task inventory
* Added ScriptingConsole, which allows you to run LSL functions from the chat console
* Added new PacketCategory, Messaging, for chat-related packets
* Fixed InventoryObject overrides
* Added a NotecardCache, useful for the scripting engine and may become generally useful later
* Added several helper functions and new members to SimulationObject

git-svn-id: http://libopenmetaverse.googlecode.com/svn/libopenmetaverse/trunk@2462 52acb1d6-8a22-11de-b505-999d5b087335
2009-03-02 23:00:28 +00:00

117 lines
3.3 KiB
C#

using System;
using System.Collections.Generic;
using ExtensionLoader;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
namespace Simian.Extensions
{
public class AccountManager : IExtension<Simian>, IAccountProvider, IPersistable
{
Simian server;
DoubleDictionary<string, UUID, Agent> accounts = new DoubleDictionary<string, UUID, Agent>();
public AccountManager()
{
}
public void Start(Simian server)
{
this.server = server;
}
public void Stop()
{
}
public void AddAccount(Agent agent)
{
accounts.Add(agent.FullName, agent.Avatar.ID, agent);
}
public bool RemoveAccount(UUID agentID)
{
Agent agent;
if (accounts.TryGetValue(agentID, out agent))
return accounts.Remove(agent.FullName, agentID);
else
return false;
}
public Agent CreateInstance(UUID agentID)
{
Agent agent;
if (accounts.TryGetValue(agentID, out agent))
{
// Random session IDs
agent.SessionID = UUID.Random();
agent.SecureSessionID = UUID.Random();
// Avatar flags
agent.Flags = PrimFlags.Physics;
return agent;
}
else
{
Logger.Log(String.Format("Agent {0} does not exist in the account store", agentID),
Helpers.LogLevel.Error);
return null;
}
}
public bool TryGetAccount(UUID agentID, out Agent agent)
{
return accounts.TryGetValue(agentID, out agent);
}
public bool TryGetAccount(string fullName, out Agent agent)
{
return accounts.TryGetValue(fullName, out agent);
}
#region Persistence
public OSD Serialize()
{
OSDArray array = new OSDArray(accounts.Count);
accounts.ForEach(delegate(Agent agent)
{
OSDMap agentMap = OSD.SerializeMembers(agent);
agentMap["AgentID"] = OSD.FromUUID(agent.Avatar.ID);
array.Add(agentMap);
});
Logger.Log(String.Format("Serializing the agent store with {0} entries", accounts.Count),
Helpers.LogLevel.Info);
return array;
}
public void Deserialize(OSD serialized)
{
accounts.Clear();
OSDArray array = (OSDArray)serialized;
for (int i = 0; i < array.Count; i++)
{
Agent agent = new Agent();
object agentRef = (object)agent;
OSDMap map = array[i] as OSDMap;
OSD.DeserializeMembers(ref agentRef, map);
agent = (Agent)agentRef;
agent.Avatar.ID = map["AgentID"].AsUUID();
accounts.Add(agent.FullName, agent.Avatar.ID, agent);
}
Logger.Log(String.Format("Deserialized the agent store with {0} entries", accounts.Count),
Helpers.LogLevel.Info);
}
#endregion Persistence
}
}