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


C# BitStream.ReadCompressed方法代码示例

本文整理汇总了C#中BitStream.ReadCompressed方法的典型用法代码示例。如果您正苦于以下问题:C# BitStream.ReadCompressed方法的具体用法?C# BitStream.ReadCompressed怎么用?C# BitStream.ReadCompressed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BitStream的用法示例。


在下文中一共展示了BitStream.ReadCompressed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: clientRPC

        public static void clientRPC(RPCParameters rpcParameters)
        {
            BitStream b = new BitStream(rpcParameters, false);
            string name;

            if (!b.Read(out name))
            {
                Console.Write("Too-short bitstreams.\n");
                return;
            }

            Console.Write("In clientRPC:\n");
            Console.Write("Name is {0}\n", name);

            uint age;
            if (!b.ReadCompressed(out age))
            {
                return;
            }

            Console.Write("Age is {0}\n", age);
            Console.Out.Flush();

            bool wroteEmploymentStruct;
            if (!b.Read(out wroteEmploymentStruct))
            {
                return;
            }

            if (wroteEmploymentStruct)
            {
                Console.Write("We are employed.\n");

                EmploymentStruct employmentStruct;
                if (!b.Read(out employmentStruct.salary)) return;
                if (!b.Read(out employmentStruct.yearsEmployed)) return;

                Console.Write("Salary is {0}.  Years employed is {1}\n", employmentStruct.salary, employmentStruct.yearsEmployed);
            }
            else
                Console.Write("We are between jobs :)\n");

            quit = true;
        }
开发者ID:JetCrusherTorpedo,项目名称:raknetdotnet,代码行数:44,代码来源:Program.cs

示例2: ProcessReplication

        internal void ProcessReplication(BitStream bs)
        {
            bool success;

            int typeID;
            success = bs.ReadCompressed(out typeID);
            Debug.Assert(success, "Failed to read replication type ID");
            Debug.Assert(typeID < m_idToType.Count, "Invalid replication type ID");

            Type type = m_idToType[typeID];

            long tmpLong;
            success = bs.Read(out tmpLong);
            Debug.Assert(success, "Failed to read entityID");
            ulong entityID = (ulong)tmpLong;

            object obj = Activator.CreateInstance(type);
            MySyncedClass sync = GetSyncedClass(obj);
            sync.TypeID = typeID;
            sync.EntityId = entityID;
            sync.Deserialize(bs);
            // TODO:SK should init here

            RegisterSynced(sync);

            var handle = OnEntityCreated;
            if (handle != null)
            {
                handle(obj, entityID);
            }
        }
开发者ID:caomw,项目名称:SpaceEngineers,代码行数:31,代码来源:MyRakNetSyncLayer.cs


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