本文整理汇总了C#中System.IO.PacketReader.ReadBytes方法的典型用法代码示例。如果您正苦于以下问题:C# PacketReader.ReadBytes方法的具体用法?C# PacketReader.ReadBytes怎么用?C# PacketReader.ReadBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.PacketReader
的用法示例。
在下文中一共展示了PacketReader.ReadBytes方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Recv
//.........这里部分代码省略.........
if (m_security_flags.security_bytes == 1)
{
byte expected_count = GenerateCountByte(true);
if (packet_security_count != expected_count)
{
//throw (new Exception("[SecurityAPI::Recv] Count byte mismatch on {packet_opcode.ToString("X4")}."));
StaticLogger.Instance.Warn($"[SecurityAPI::Recv] Count byte mismatch on {packet_opcode.ToString("X4")}. (Expected: {expected_count}, Packet: {packet_security_count})");
}
if (packet_encrypted || (m_security_flags.security_bytes == 1 && m_security_flags.blowfish == 0))
{
if (packet_encrypted || m_enc_opcodes.Contains(packet_opcode))
{
packet_size |= 0x8000;
Buffer.BlockCopy(BitConverter.GetBytes((ushort)packet_size), 0, buffer.Buffer, 0, 2);
}
}
buffer.Buffer[5] = 0;
byte expected_crc = GenerateCheckByte(buffer.Buffer);
if (packet_security_crc != expected_crc)
{
//throw (new Exception("[SecurityAPI::Recv] CRC byte mismatch."));
StaticLogger.Instance.Warn($"[SecurityAPI::Recv] CRC byte mismatch on {packet_opcode.ToString("X4")}. (Expected: {expected_crc}, Packet: {packet_security_crc})");
}
buffer.Buffer[4] = 0;
if (packet_encrypted || (m_security_flags.security_bytes == 1 && m_security_flags.blowfish == 0))
{
if (packet_encrypted || m_enc_opcodes.Contains(packet_opcode))
{
packet_size &= 0x7FFF;
Buffer.BlockCopy(BitConverter.GetBytes((ushort)packet_size), 0, buffer.Buffer, 0, 2);
}
}
}
}
if (packet_opcode == 0x5000 || packet_opcode == 0x9000) // New logic processing!
{
Handshake(packet_opcode, packet_data, packet_encrypted);
// Pass the handshake packets to the user so they can at least see them.
// They do not need to actually do anything with them. This was added to
// help debugging and make output logs complete.
Packet packet = new Packet(packet_opcode, packet_encrypted, false, buffer.Buffer, 6, packet_size);
packet.Lock();
m_incoming_packets.Add(packet);
}
else
{
if (m_client_security)
{
// Make sure the client accepted the security system first
if (!m_accepted_handshake)
{
throw (new Exception("[SecurityAPI::Recv] The client has not accepted the handshake."));
}
}
if (packet_opcode == 0x600D) // Auto process massive messages for the user
{
byte mode = packet_data.ReadByte();
if (mode == 1)
{
m_massive_count = packet_data.ReadUInt16();
ushort contained_packet_opcode = packet_data.ReadUInt16();
m_massive_packet = new Packet(contained_packet_opcode, packet_encrypted, true);
}
else
{
if (m_massive_packet == null)
{
throw (new Exception("[SecurityAPI::Recv] A malformed 0x600D packet was received."));
}
m_massive_packet.WriteByteArray(packet_data.ReadBytes(packet_size - 1));
m_massive_count--;
if (m_massive_count == 0)
{
m_massive_packet.Lock();
m_incoming_packets.Add(m_massive_packet);
m_massive_packet = null;
}
}
}
else
{
Packet packet = new Packet(packet_opcode, packet_encrypted, false, buffer.Buffer, 6, packet_size);
packet.Lock();
m_incoming_packets.Add(packet);
}
}
}
}
}
}
示例2: Read
public override void Read(PacketReader reader)
{
SharedSecretLength = reader.ReadShort();
SharedSecret = reader.ReadBytes(SharedSecretLength);
VerifyTokenLength = reader.ReadShort();
VerifyToken = reader.ReadBytes(VerifyTokenLength);
}
示例3: Read
public override void Read(PacketReader stream)
{
UnknownConstantValue = stream.ReadShort();
UnknownMapId = stream.ReadShort();
TextLength = stream.ReadByte();
Text = stream.ReadBytes(TextLength);
}