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


C# Stream.ReadBoolean方法代码示例

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


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

示例1: ReadBody

 public static ForwardedSubscriptionRequest ReadBody(Stream stream)
 {
     var clientId = stream.ReadInt32();
     var topic = stream.ReadString();
     var isAdd = stream.ReadBoolean();
     return new ForwardedSubscriptionRequest(clientId, topic, isAdd);
 }
开发者ID:rob-blackbourn,项目名称:TopicBus,代码行数:7,代码来源:ForwardedSubscriptionRequest.cs

示例2: ReadBody

        public static MulticastData ReadBody(Stream stream)
        {
            var topic = stream.ReadString();
            var isImage = stream.ReadBoolean();

            var nbytes = stream.ReadInt32();
            var data = new byte[nbytes];
            var offset = 0;
            while (nbytes > 0)
            {
                var bytesRead = stream.Read(data, offset, nbytes);
                if (bytesRead == 0)
                    throw new EndOfStreamException();
                nbytes -= bytesRead;
                offset += bytesRead;
            }

            return new MulticastData(topic, isImage, data);
        }
开发者ID:rob-blackbourn,项目名称:TopicBus,代码行数:19,代码来源:MulticastData.cs

示例3: FromStream

        public static SetupMessage FromStream(DateTime timestamp, Stream stream)
        {
            bool? ex = stream.ReadNullBoolean();
            bool? low = stream.ReadNullBoolean();

            int count = stream.ReadInt32();
            var contributors = new Models.GameSettings.Contributor[count];
            for (int i = 0; i < count; i++)
            {
                var name = stream.ReadString();
                var active = stream.ReadBoolean();
                contributors[i] = new Models.GameSettings.Contributor() { Name = name, Active = active };
            }

            var settings = new Models.GameSettings()
            {
                ExcludeMerges = ex,
                LowerCase = low,
                Contributors = contributors
            };

            return new SetupMessage(timestamp, settings);
        }
开发者ID:SickTeam,项目名称:GitGameServer,代码行数:23,代码来源:SetupMessage.cs

示例4: Unpack

        public void Unpack(Stream stream)
        {
            var flags = (TileFlags) stream.ReadInt8();

            Active = flags.HasFlag(TileFlags.Active);
            if (Active)
            {
                Type = stream.ReadInt8();
                if (FrameImportant)
                {
                    FrameX = stream.ReadInt16();
                    FrameY = stream.ReadInt16();
                }
            }

            if (flags.HasFlag(TileFlags.Wall))
            {
                Wall = stream.ReadInt8();
            }

            if (flags.HasFlag(TileFlags.Liquid))
            {
                Liquid = stream.ReadInt8();
                Lava = stream.ReadBoolean();
            }

            if (flags.HasFlag(TileFlags.Wire))
                Wire = true;
        }
开发者ID:kmcfate,项目名称:TShock,代码行数:29,代码来源:NetTile.cs

示例5: ReadFromStream

 public override void ReadFromStream(Stream aStream)
 {
     UserID = aStream.ReadInt ();
     TargetID = aStream.ReadInt ();
     LeftClick = aStream.ReadBoolean ();
 }
开发者ID:rbrian,项目名称:mccslib,代码行数:6,代码来源:Packets.cs

示例6: Read

 public static object Read(Stream stream)
 {
     return stream.ReadBoolean();
 }
开发者ID:FPCollab,项目名称:General,代码行数:4,代码来源:FastPacker.cs

示例7: ReadBody

 public static SubscriptionRequest ReadBody(Stream stream)
 {
     var topic = stream.ReadString();
     var isAdd = stream.ReadBoolean();
     return new SubscriptionRequest(topic, isAdd);
 }
开发者ID:rob-blackbourn,项目名称:TopicBus,代码行数:6,代码来源:SubscriptionRequest.cs

示例8: TryResumeSession

        private bool TryResumeSession(ref Stream secureStream, Stream stream2, byte[] certSignatures)
        {
#if SQLCLR
            return false;
#else
            if (m_resumeTicket != null && m_sessionSecret != null)
            {
                //Resume Session:
                // C => S
                // byte    ResumeSession
                // byte    TicketLength
                // byte[]  Ticket
                // byte    ClientChallengeLength
                // byte[]  ClientChallenge

                byte[] clientChallenge = SaltGenerator.Create(16);
                stream2.WriteByte((byte)AuthenticationMode.ResumeSession);
                stream2.WriteByte((byte)m_resumeTicket.Length);
                stream2.Write(m_resumeTicket);
                stream2.WriteByte((byte)clientChallenge.Length);
                stream2.Write(clientChallenge);
                stream2.Flush();

                // S <= C
                // byte    HashMethod
                // byte    ServerChallengeLength
                // byte[]  ServerChallenge

                HashMethod hashMethod = (HashMethod)stream2.ReadNextByte();
                IDigest hash = Scram.CreateDigest(hashMethod);
                byte[] serverChallenge = stream2.ReadBytes(stream2.ReadNextByte());

                // C => S
                // byte    ClientResponseLength
                // byte[]  ClientChallenge

                byte[] clientResponse = hash.ComputeHash(serverChallenge, clientChallenge, m_sessionSecret, certSignatures);
                byte[] serverResponse = hash.ComputeHash(clientChallenge, serverChallenge, m_sessionSecret, certSignatures);

                stream2.WriteByte((byte)clientResponse.Length);
                stream2.Write(clientResponse);
                stream2.Flush();

                // S => C
                // bool   IsSuccessful
                // byte   ServerResponseLength
                // byte[] ServerResponse

                if (stream2.ReadBoolean())
                {
                    byte[] serverResponseCheck = stream2.ReadBytes(stream2.ReadNextByte());

                    // C => S
                    // bool   IsSuccessful
                    if (serverResponse.SecureEquals(serverResponseCheck))
                    {
                        stream2.Write(true);
                        stream2.Flush();
                        secureStream = stream2;
                        return true;
                    }

                    stream2.Write(false);
                    stream2.Flush();
                }

                m_resumeTicket = null;
                m_sessionSecret = null;
            }
            return false;
#endif
        }
开发者ID:GridProtectionAlliance,项目名称:openHistorian,代码行数:72,代码来源:SecureStreamClientBase.cs

示例9: Authenticate

        private bool Authenticate(Stream stream, byte[] additionalChallenge)
        {
            HashMethod passwordHashMethod = (HashMethod)stream.ReadNextByte();
            byte[] salt = stream.ReadBytes(stream.ReadNextByte());
            int iterations = stream.ReadInt32();

            SetHashMethod((HashMethod)stream.ReadNextByte());
            SetSrpStrength((SrpStrength)stream.ReadInt32());

            m_credentials.TryUpdate(passwordHashMethod, salt, iterations);

            BigInteger pubA = m_client.GenerateClientCredentials(m_hash, salt, m_credentials.UsernameBytes, m_credentials.SaltedPassword);
            byte[] pubABytes = pubA.ToPaddedArray(m_srpByteLength);

            stream.Write(pubABytes);
            stream.Flush();

            //Read from Server: B
            byte[] pubBBytes = stream.ReadBytes(m_srpByteLength);
            BigInteger pubB = new BigInteger(1, pubBBytes);

            //Calculate Session Key
            BigInteger S = m_client.CalculateSecret(m_hash, pubB);
            byte[] SBytes = S.ToPaddedArray(m_srpByteLength);

            byte[] clientProof = m_hash.ComputeHash(pubABytes, pubBBytes, SBytes, additionalChallenge);
            stream.Write(clientProof);
            stream.Flush();

            byte[] serverProof = m_hash.ComputeHash(pubBBytes, pubABytes, SBytes, additionalChallenge);

            if (stream.ReadBoolean())
            {
                byte[] serverProofCheck = stream.ReadBytes(m_hash.GetDigestSize());
                int ticketLength = stream.ReadInt16();
                if (ticketLength < 0 || ticketLength > 10000)
                    return false;

                if (serverProofCheck.SecureEquals(serverProof))
                {
                    m_resumeTicket = stream.ReadBytes(ticketLength);
                    m_sessionSecret = m_hash.ComputeHash(pubABytes, SBytes, pubBBytes).Combine(m_hash.ComputeHash(pubBBytes, SBytes, pubABytes));
                    return true;
                }
                return false;
            }
            return false;
        }
开发者ID:GridProtectionAlliance,项目名称:openHistorian,代码行数:48,代码来源:SrpClient.cs

示例10: ResumeSession

        private bool ResumeSession(Stream stream, byte[] additionalChallenge)
        {
            stream.Write((byte)16);
            byte[] aChallenge = SaltGenerator.Create(16);
            stream.Write(aChallenge);
            stream.Write((short)m_resumeTicket.Length);
            stream.Write(m_resumeTicket);
            stream.Flush();

            if (stream.ReadBoolean())
            {
                SetHashMethod((HashMethod)stream.ReadNextByte());
                byte[] bChallenge = stream.ReadBytes(stream.ReadNextByte());

                byte[] clientProof = m_hash.ComputeHash(aChallenge, bChallenge, m_sessionSecret, additionalChallenge);
                stream.Write(clientProof);
                stream.Flush();

                if (stream.ReadBoolean())
                {
                    byte[] serverProof = m_hash.ComputeHash(bChallenge, aChallenge, m_sessionSecret, additionalChallenge);
                    byte[] serverProofCheck = stream.ReadBytes(m_hash.GetDigestSize());

                    return serverProof.SecureEquals(serverProofCheck);
                }

            }
            m_sessionSecret = null;
            m_resumeTicket = null;
            return Authenticate(stream, additionalChallenge);
        }
开发者ID:GridProtectionAlliance,项目名称:openHistorian,代码行数:31,代码来源:SrpClient.cs

示例11: ReadBody

 public static NotificationRequest ReadBody(Stream stream)
 {
     var topicPattern = stream.ReadString();
     var isAdd = stream.ReadBoolean();
     return new NotificationRequest(topicPattern, isAdd);
 }
开发者ID:rob-blackbourn,项目名称:TopicBus,代码行数:6,代码来源:NotificationRequest.cs


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