当前位置: 首页>>代码示例>>C#>>正文


C# LLSDMap类代码示例

本文整理汇总了C#中LLSDMap的典型用法代码示例。如果您正苦于以下问题:C# LLSDMap类的具体用法?C# LLSDMap怎么用?C# LLSDMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


LLSDMap类属于命名空间,在下文中一共展示了LLSDMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的LLSDMap类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。