本文整理汇总了C#中LLSDMap类的典型用法代码示例。如果您正苦于以下问题:C# LLSDMap类的具体用法?C# LLSDMap怎么用?C# LLSDMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LLSDMap类属于命名空间,在下文中一共展示了LLSDMap类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: BuildPacket
/// <summary>
/// Attempts to convert an LLSD structure to a known Packet type
/// </summary>
/// <param name="capsEventName">Event name, this must match an actual
/// packet name for a Packet to be successfully built</param>
/// <param name="body">LLSD to convert to a Packet</param>
/// <returns>A Packet on success, otherwise null</returns>
public static Packet BuildPacket(string capsEventName, LLSDMap body)
{
Assembly assembly = Assembly.GetExecutingAssembly();
// Check if we have a subclass of packet with the same name as this event
Type type = assembly.GetType("OpenMetaverse.Packets." + capsEventName + "Packet", false);
if (type == null)
return null;
Packet packet = null;
try
{
// Create an instance of the object
packet = (Packet)Activator.CreateInstance(type);
// Iterate over all of the fields in the packet class, looking for matches in the LLSD
foreach (FieldInfo field in type.GetFields())
{
if (body.ContainsKey(field.Name))
{
Type blockType = field.FieldType;
if (blockType.IsArray)
{
LLSDArray array = (LLSDArray)body[field.Name];
Type elementType = blockType.GetElementType();
object[] blockArray = (object[])Array.CreateInstance(elementType, array.Count);
for (int i = 0; i < array.Count; i++)
{
LLSDMap map = (LLSDMap)array[i];
blockArray[i] = ParseLLSDBlock(map, elementType);
}
field.SetValue(packet, blockArray);
}
else
{
LLSDMap map = (LLSDMap)((LLSDArray)body[field.Name])[0];
field.SetValue(packet, ParseLLSDBlock(map, blockType));
}
}
}
}
catch (Exception e)
{
Logger.Log(e.Message, Helpers.LogLevel.Error, e);
}
return packet;
}
开发者ID:jhs,项目名称:libopenmetaverse,代码行数:59,代码来源:CapsToPacket.cs
示例2: GetLLSD
public static LLSD GetLLSD(Packet packet)
{
LLSDMap body = new LLSDMap();
Type type = packet.GetType();
foreach (FieldInfo field in type.GetFields())
{
if (field.IsPublic)
{
Type blockType = field.FieldType;
if (blockType.IsArray)
{
object blockArray = field.GetValue(packet);
Array array = (Array)blockArray;
LLSDArray blockList = new LLSDArray(array.Length);
IEnumerator ie = array.GetEnumerator();
while (ie.MoveNext())
{
object block = ie.Current;
blockList.Add(BuildLLSDBlock(block));
}
body[field.Name] = blockList;
}
else
{
object block = field.GetValue(packet);
body[field.Name] = BuildLLSDBlock(block);
}
}
}
return body;
}
开发者ID:RavenB,项目名称:gridsearch,代码行数:36,代码来源:CapsToPacket.cs
示例3: ParseBinaryMap
private static LLSD ParseBinaryMap(MemoryStream stream)
{
int numElements = NetworkToHostInt( ConsumeBytes( stream, int32Length ));
int crrElement = 0;
LLSDMap llsdMap = new LLSDMap();
while( crrElement < numElements )
{
if (!FindByte( stream, keyBinaryMarker ))
throw new LLSDException( "Binary LLSD parsing: Missing key marker in map." );
int keyLength = NetworkToHostInt( ConsumeBytes( stream, int32Length ));
string key = Encoding.UTF8.GetString( ConsumeBytes( stream, keyLength ));
llsdMap[key] = ParseBinaryElement( stream );
crrElement++;
}
if ( !FindByte( stream, mapEndBinaryMarker ))
throw new LLSDException( "Binary LLSD parsing: Missing end marker in map." );
return (LLSD)llsdMap;
}
开发者ID:RavenB,项目名称:gridsearch,代码行数:20,代码来源:BinaryLLSD.cs
示例4: ToLLSD
public LLSD ToLLSD()
{
LLSDMap map = new LLSDMap();
map["color"] = Color.ToLLSD();
map["intensity"] = LLSD.FromReal(Intensity);
map["radius"] = LLSD.FromReal(Radius);
map["cutoff"] = LLSD.FromReal(Cutoff);
map["falloff"] = LLSD.FromReal(Falloff);
return map;
}
开发者ID:chrbayer84,项目名称:SLAgentCSServer,代码行数:12,代码来源:Prims.cs
示例5: SerializeBinaryMap
private static void SerializeBinaryMap( MemoryStream stream, LLSDMap llsdMap )
{
stream.WriteByte( mapBeginBinaryMarker );
byte[] binaryNumElementsNetEnd = HostToNetworkIntBytes( llsdMap.Count );
stream.Write( binaryNumElementsNetEnd, 0, int32Length );
foreach( KeyValuePair<string, LLSD> kvp in llsdMap )
{
stream.WriteByte( keyBinaryMarker );
byte[] binaryKey = Encoding.UTF8.GetBytes( kvp.Key );
byte[] binaryKeyLength = HostToNetworkIntBytes( binaryKey.Length );
stream.Write( binaryKeyLength, 0, int32Length );
stream.Write( binaryKey, 0, binaryKey.Length );
SerializeBinaryElement( stream, kvp.Value );
}
stream.WriteByte( mapEndBinaryMarker );
}
开发者ID:RavenB,项目名称:gridsearch,代码行数:17,代码来源:BinaryLLSD.cs
示例6: EventQueueEventHandler
private void EventQueueEventHandler(string eventName, LLSDMap body)
{
if (Simulator.Client.Settings.SYNC_PACKETCALLBACKS)
Simulator.Client.Network.CapsEvents.RaiseEvent(eventName, body, Simulator);
else
Simulator.Client.Network.CapsEvents.BeginRaiseEvent(eventName, body, Simulator);
}
开发者ID:RavenB,项目名称:gridsearch,代码行数:7,代码来源:Caps.cs
示例7: RequestMapLayer
/// <summary>
///
/// </summary>
/// <param name="layer"></param>
public void RequestMapLayer(GridLayerType layer)
{
Uri url = Client.Network.CurrentSim.Caps.CapabilityURI("MapLayer");
if (url != null)
{
LLSDMap body = new LLSDMap();
body["Flags"] = LLSD.FromInteger((int)layer);
CapsClient request = new CapsClient(url);
request.OnComplete += new CapsClient.CompleteCallback(MapLayerResponseHandler);
request.StartRequest(body);
}
}
开发者ID:RavenB,项目名称:gridsearch,代码行数:18,代码来源:GridManager.cs
示例8: ParseInventoryFolders
public static FolderData[] ParseInventoryFolders(string key, UUID owner, LLSDMap reply)
{
List<FolderData> folders = new List<FolderData>();
LLSD skeleton;
if (reply.TryGetValue(key, out skeleton) && skeleton.Type == LLSDType.Array)
{
LLSDArray array = (LLSDArray)skeleton;
for (int i = 0; i < array.Count; i++)
{
if (array[i].Type == LLSDType.Map)
{
LLSDMap map = (LLSDMap)array[i];
FolderData folder = new FolderData(map["folder_id"].AsUUID());
folder.PreferredType = (AssetType)map["type_default"].AsInteger();
folder.Version = map["version"].AsInteger();
folder.OwnerID = owner;
folder.ParentUUID = map["parent_id"].AsUUID();
folder.Name = map["name"].AsString();
folders.Add(folder);
}
}
}
return folders.ToArray();
}
开发者ID:RavenB,项目名称:gridsearch,代码行数:28,代码来源:Login.cs
示例9: RequestUploadNotecardAsset
/// <summary>
///
/// </summary>
/// <param name="data"></param>
/// <param name="notecardID"></param>
/// <param name="callback"></param>
public void RequestUploadNotecardAsset(byte[] data, UUID notecardID, NotecardUploadedAssetCallback callback)
{
if (_Network.CurrentSim == null || _Network.CurrentSim.Caps == null)
throw new Exception("UpdateNotecardAgentInventory capability is not currently available");
Uri url = _Network.CurrentSim.Caps.CapabilityURI("UpdateNotecardAgentInventory");
if (url != null)
{
LLSDMap query = new LLSDMap();
query.Add("item_id", LLSD.FromUUID(notecardID));
byte[] postData = StructuredData.LLSDParser.SerializeXmlBytes(query);
// Make the request
CapsClient request = new CapsClient(url);
request.OnComplete += new CapsClient.CompleteCallback(UploadNotecardAssetResponse);
request.UserData = new object[2] { new KeyValuePair<NotecardUploadedAssetCallback, byte[]>(callback, data), notecardID };
request.StartRequest(postData);
}
else
{
throw new Exception("UpdateNotecardAgentInventory capability is not currently available");
}
}
开发者ID:RavenB,项目名称:gridsearch,代码行数:31,代码来源:InventoryManager.cs
示例10: ParseUUID
public static UUID ParseUUID(string key, LLSDMap reply)
{
LLSD llsd;
if (reply.TryGetValue(key, out llsd))
return llsd.AsUUID();
else
return UUID.Zero;
}
开发者ID:RavenB,项目名称:gridsearch,代码行数:8,代码来源:Login.cs
示例11: ParseXmlMap
private static LLSDMap ParseXmlMap(XmlTextReader reader)
{
if (reader.NodeType != XmlNodeType.Element || reader.LocalName != "map")
throw new NotImplementedException("Expected <map>");
LLSDMap map = new LLSDMap();
if (reader.IsEmptyElement)
{
reader.Read();
return map;
}
if (reader.Read())
{
while (true)
{
SkipWhitespace(reader);
if (reader.NodeType == XmlNodeType.EndElement && reader.LocalName == "map")
{
reader.Read();
break;
}
if (reader.NodeType != XmlNodeType.Element || reader.LocalName != "key")
throw new LLSDException("Expected <key>");
string key = reader.ReadString();
if (reader.NodeType != XmlNodeType.EndElement || reader.LocalName != "key")
throw new LLSDException("Expected </key>");
if (reader.Read())
map[key] = ParseXmlElement(reader);
else
throw new LLSDException("Failed to parse a value for key " + key);
}
}
return map;
}
开发者ID:RavenB,项目名称:gridsearch,代码行数:42,代码来源:XmlLLSD.cs
示例12: RequestCreateItemFromAsset
public void RequestCreateItemFromAsset(byte[] data, string name, string description, AssetType assetType,
InventoryType invType, UUID folderID, CapsClient.ProgressCallback progCallback, ItemCreatedFromAssetCallback callback)
{
if (_Network.CurrentSim == null || _Network.CurrentSim.Caps == null)
throw new Exception("NewFileAgentInventory capability is not currently available");
Uri url = _Network.CurrentSim.Caps.CapabilityURI("NewFileAgentInventory");
if (url != null)
{
LLSDMap query = new LLSDMap();
query.Add("folder_id", LLSD.FromUUID(folderID));
query.Add("asset_type", LLSD.FromString(AssetTypeToString(assetType)));
query.Add("inventory_type", LLSD.FromString(InventoryTypeToString(invType)));
query.Add("name", LLSD.FromString(name));
query.Add("description", LLSD.FromString(description));
// Make the request
CapsClient request = new CapsClient(url);
request.OnComplete += new CapsClient.CompleteCallback(CreateItemFromAssetResponse);
request.UserData = new object[] { progCallback, callback, data };
request.StartRequest(query);
}
else
{
throw new Exception("NewFileAgentInventory capability is not currently available");
}
}
开发者ID:RavenB,项目名称:gridsearch,代码行数:29,代码来源:InventoryManager.cs
示例13: Client_OpenWriteCompleted
private void Client_OpenWriteCompleted(object sender, CapsBase.OpenWriteCompletedEventArgs e)
{
bool raiseEvent = false;
if (!_Dead)
{
if (!_Running) raiseEvent = true;
// We are connected to the event queue
_Running = true;
}
// Create an EventQueueGet request
LLSDMap request = new LLSDMap();
request["ack"] = new LLSD();
request["done"] = LLSD.FromBoolean(false);
byte[] postData = LLSDParser.SerializeXmlBytes(request);
_Client.UploadDataAsync(_Client.Location, postData);
if (raiseEvent)
{
Logger.DebugLog("Capabilities event queue connected");
// The event queue is starting up for the first time
if (OnConnected != null)
{
try { OnConnected(); }
catch (Exception ex) { Logger.Log(ex.Message, Helpers.LogLevel.Error, ex); }
}
}
}
开发者ID:RavenB,项目名称:gridsearch,代码行数:33,代码来源:EventQueueClient.cs
示例14: Client_UploadDataCompleted
private void Client_UploadDataCompleted(object sender, CapsBase.UploadDataCompletedEventArgs e)
{
LLSDArray events = null;
int ack = 0;
if (e.Error != null)
{
// Error occurred
string message = e.Error.Message.ToLower();
// Check what kind of exception happened
if (Helpers.StringContains(message, "404") || Helpers.StringContains(message, "410"))
{
Logger.Log("Closing event queue at " + _Client.Location + " due to missing caps URI",
Helpers.LogLevel.Info);
_Running = false;
_Dead = true;
}
else if (!e.Cancelled)
{
HttpWebResponse errResponse = null;
if (e.Error is WebException)
{
WebException err = (WebException)e.Error;
errResponse = (HttpWebResponse)err.Response;
}
// Figure out what type of error was thrown so we can print a meaningful
// error message
if (errResponse != null)
{
switch (errResponse.StatusCode)
{
case HttpStatusCode.BadGateway:
// This is not good (server) protocol design, but it's normal.
// The EventQueue server is a proxy that connects to a Squid
// cache which will time out periodically. The EventQueue server
// interprets this as a generic error and returns a 502 to us
// that we ignore
break;
default:
Logger.Log(String.Format(
"Unrecognized caps connection problem from {0}: {1} (Server returned: {2})",
_Client.Location, errResponse.StatusCode, errResponse.StatusDescription),
Helpers.LogLevel.Warning);
break;
}
}
else if (e.Error.InnerException != null)
{
Logger.Log(String.Format("Unrecognized caps exception from {0}: {1}",
_Client.Location, e.Error.InnerException.Message), Helpers.LogLevel.Warning);
}
else
{
Logger.Log(String.Format("Unrecognized caps exception from {0}: {1}",
_Client.Location, e.Error.Message), Helpers.LogLevel.Warning);
}
}
}
else if (!e.Cancelled && e.Result != null)
{
// Got a response
LLSD result = LLSDParser.DeserializeXml(e.Result);
if (result != null && result.Type == LLSDType.Map)
{
// Parse any events returned by the event queue
LLSDMap map = (LLSDMap)result;
events = (LLSDArray)map["events"];
ack = map["id"].AsInteger();
}
}
else if (e.Cancelled)
{
// Connection was cancelled
Logger.DebugLog("Cancelled connection to event queue at " + _Client.Location);
}
if (_Running)
{
LLSDMap request = new LLSDMap();
if (ack != 0) request["ack"] = LLSD.FromInteger(ack);
else request["ack"] = new LLSD();
request["done"] = LLSD.FromBoolean(_Dead);
byte[] postData = LLSDParser.SerializeXmlBytes(request);
_Client.UploadDataAsync(_Client.Location, postData);
// If the event queue is dead at this point, turn it off since
// that was the last thing we want to do
if (_Dead)
{
_Running = false;
Logger.DebugLog("Sent event queue shutdown message");
}
}
//.........这里部分代码省略.........
开发者ID:RavenB,项目名称:gridsearch,代码行数:101,代码来源:EventQueueClient.cs
示例15: FixupSeedCapsResponse
private bool FixupSeedCapsResponse(CapsRequest capReq, CapsStage stage)
{
if (stage != CapsStage.Response) return false;
LLSDMap nm = new LLSDMap();
if (capReq.Response.Type == LLSDType.Map)
{
LLSDMap m = (LLSDMap)capReq.Response;
foreach (string key in m.Keys)
{
string val = m[key].AsString();
if (!String.IsNullOrEmpty(val))
{
if (!KnownCaps.ContainsKey(val))
{
CapInfo newCap = new CapInfo(val, capReq.Info.Sim, key);
newCap.AddDelegate(new CapsDelegate(KnownCapDelegate));
lock (this) { KnownCaps[val] = newCap; }
}
nm[key] = LLSD.FromString(loginURI + val);
}
else
{
nm[key] = LLSD.FromString(val);
}
}
}
capReq.Response = nm;
return false;
}
开发者ID:RavenB,项目名称:gridsearch,代码行数:34,代码来源:GridProxy.cs
示例16: Parse
public void Parse(LLSDMap reply)
{
try
{
AgentID = ParseUUID("agent_id", reply);
SessionID = ParseUUID("session_id", reply);
SecureSessionID = ParseUUID("secure_session_id", reply);
FirstName = ParseString("first_name", reply).Trim('"');
LastName = ParseString("last_name", reply).Trim('"');
StartLocation = ParseString("start_location", reply);
AgentAccess = ParseString("agent_access", reply);
LookAt = ParseVector3("look_at", reply);
}
catch (LLSDException e)
{
// FIXME: sometimes look_at comes back with invalid values e.g: 'look_at':'[r1,r2.0193899999999998204e-06,r0]'
// need to handle that somehow
Logger.DebugLog("login server returned (some) invalid data: " + e.Message);
}
// Home
LLSDMap home = null;
LLSD llsdHome = LLSDParser.DeserializeNotation(reply["home"].AsString());
if (llsdHome.Type == LLSDType.Map)
{
home = (LLSDMap)llsdHome;
LLSD homeRegion;
if (home.TryGetValue("region_handle", out homeRegion) && homeRegion.Type == LLSDType.Array)
{
LLSDArray homeArray = (LLSDArray)homeRegion;
if (homeArray.Count == 2)
HomeRegion = Helpers.UIntsToLong((uint)homeArray[0].AsInteger(), (uint)homeArray[1].AsInteger());
else
HomeRegion = 0;
}
HomePosition = ParseVector3("position", home);
HomeLookAt = ParseVector3("look_at", home);
}
else
{
HomeRegion = 0;
HomePosition = Vector3.Zero;
HomeLookAt = Vector3.Zero;
}
CircuitCode = ParseUInt("circuit_code", reply);
RegionX = ParseUInt("region_x", reply);
RegionY = ParseUInt("region_y", reply);
SimPort = (ushort)ParseUInt("sim_port", reply);
string simIP = ParseString("sim_ip", reply);
IPAddress.TryParse(simIP, out SimIP);
SeedCapability = ParseString("seed_capability", reply);
// Buddy list
LLSD buddyLLSD;
if (reply.TryGetValue("buddy-list", out buddyLLSD) && buddyLLSD.Type == LLSDType.Array)
{
LLSDArray buddyArray = (LLSDArray)buddyLLSD;
BuddyList = new FriendInfo[buddyArray.Count];
for (int i = 0; i < buddyArray.Count; i++)
{
if (buddyArray[i].Type == LLSDType.Map)
{
LLSDMap buddy = (LLSDMap)buddyArray[i];
BuddyList[i] = new FriendInfo(
ParseUUID("buddy_id", buddy),
(FriendRights)ParseUInt("buddy_rights_given", buddy),
(FriendRights)ParseUInt("buddy_rights_has", buddy));
}
}
}
SecondsSinceEpoch = Helpers.UnixTimeToDateTime(ParseUInt("seconds_since_epoch", reply));
InventoryRoot = ParseMappedUUID("inventory-root", "folder_id", reply);
InventoryFolders = ParseInventoryFolders("inventory-skeleton", AgentID, reply);
LibraryRoot = ParseMappedUUID("inventory-lib-root", "folder_id", reply);
LibraryOwner = ParseMappedUUID("inventory-lib-owner", "agent_id", reply);
LibraryFolders = ParseInventoryFolders("inventory-skel-lib", LibraryOwner, reply);
}
开发者ID:RavenB,项目名称:gridsearch,代码行数:83,代码来源:Login.cs
示例17: ParseVector3
public static Vector3 ParseVector3(string key, LLSDMap reply)
{
LLSD llsd;
if (reply.TryGetValue(key, out llsd))
{
if (llsd.Type == LLSDType.Array)
{
Vector3 vec = new Vector3();
vec.FromLLSD(llsd);
return vec;
}
else if (llsd.Type == LLSDType.String)
{
LLSDArray array = (LLSDArray)LLSDParser.DeserializeNotation(llsd.AsString());
Vector3 vec = new Vector3();
vec.FromLLSD(array);
return vec;
}
}
return Vector3.Zero;
}
开发者ID:RavenB,项目名称:gridsearch,代码行数:22,代码来源:Login.cs
示例18: ParseUInt
public static uint ParseUInt(string key, LLSDMap reply)
{
LLSD llsd;
if (reply.TryGetValue(key, out llsd))
return (uint)llsd.AsInteger();
else
return 0;
}
开发者ID:RavenB,项目名称:gridsearch,代码行数:8,代码来源:Login.cs
示例19: ParseString
public static string ParseString(string key, LLSDMap reply)
{
LLSD llsd;
if (reply.TryGetValue(key, out llsd))
return llsd.AsString();
else
return String.Empty;
}
开发者ID:RavenB,项目名称:gridsearch,代码行数:8,代码来源:Login.cs
示例20: ModerateChatSessions
/// <summary>
/// Moderate a chat session
/// </summary>
/// <param name="sessionID">the <see cref="UUID"/> of the session to moderate, for group chats this will be the groups UUID</param>
/// <param name="memberID">the <see cref="UUID"/> of the avatar to moderate</param>
/// <param name="moderateText">true to moderate (silence user), false to allow avatar to speak</param>
public void ModerateChatSessions(UUID sessionID, UUID memberID, bool moderateText)
{
if (Client.Network.CurrentSim == null || Client.Network.CurrentSim.Caps == null)
throw new Exception("ChatSessionRequest capability is not currently available");
Uri url = Client.Network.CurrentSim.Caps.CapabilityURI("ChatSessionRequest");
if (url != null)
{
LLSDMap req = new LLSDMap();
req.Add("method", LLSD.FromString("mute update"));
LLSDMap mute_info = new LLSDMap();
mute_info.Add("text", LLSD.FromBoolean(moderateText));
LLSDMap parameters = new LLSDMap();
parameters["agent_id"] = LLSD.FromUUID(memberID);
parameters["mute_info"] = mute_info;
req["params"] = parameters;
req.Add("session-id", LLSD.FromUUID(sessionID));
byte[] postData = StructuredData.LLSDParser.SerializeXmlBytes(req);
CapsClient request = new CapsClient(url);
request.StartRequest(postData);
}
else
{
throw new Exception("ChatSessionRequest capability is not currently available");
}
}
开发者ID:jhs,项目名称:libopenmetaverse,代码行数:39,代码来源:AgentManager.cs
注:本文中的LLSDMap类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论