本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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;
}
示例5: ReadFromStream
public override void ReadFromStream(Stream aStream)
{
UserID = aStream.ReadInt ();
TargetID = aStream.ReadInt ();
LeftClick = aStream.ReadBoolean ();
}
示例6: Read
public static object Read(Stream stream)
{
return stream.ReadBoolean();
}
示例7: ReadBody
public static SubscriptionRequest ReadBody(Stream stream)
{
var topic = stream.ReadString();
var isAdd = stream.ReadBoolean();
return new SubscriptionRequest(topic, isAdd);
}
示例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
}
示例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;
}
示例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);
}
示例11: ReadBody
public static NotificationRequest ReadBody(Stream stream)
{
var topicPattern = stream.ReadString();
var isAdd = stream.ReadBoolean();
return new NotificationRequest(topicPattern, isAdd);
}