public bool Read(ByteArrayReaderWriter stream, int length, byte[] key, ulong protocolID) { byte[] packetBuffer = BufferPool.GetBuffer(8 + 300 + Defines.MAC_SIZE); int packetLen = 0; try { packetLen = PacketIO.ReadPacketData(Header, stream, length, protocolID, key, packetBuffer); } catch { BufferPool.ReturnBuffer(packetBuffer); return(false); } if (packetLen != 308) { BufferPool.ReturnBuffer(packetBuffer); return(false); } ChallengeTokenBytes = BufferPool.GetBuffer(300); using (var reader = ByteArrayReaderWriter.Get(packetBuffer)) { ChallengeTokenSequence = reader.ReadUInt64(); reader.ReadBytesIntoBuffer(ChallengeTokenBytes, 300); } BufferPool.ReturnBuffer(packetBuffer); return(true); }
public bool Read(ByteArrayReaderWriter stream, int length, byte[] key, ulong protocolID) { if (length != 8 + Defines.MAC_SIZE) { return(false); } byte[] tempBuffer = BufferPool.GetBuffer(length); try { PacketIO.ReadPacketData(Header, stream, length, protocolID, key, tempBuffer); } catch { BufferPool.ReturnBuffer(tempBuffer); return(false); } using (var dataReader = ByteArrayReaderWriter.Get(tempBuffer)) { ClientIndex = dataReader.ReadUInt32(); MaxSlots = dataReader.ReadUInt32(); } return(true); }
public bool Read(ByteArrayReaderWriter stream, int length, byte[] key, ulong protocolID) { if (length != Defines.MAC_SIZE) { return(false); } byte[] tempBuffer = BufferPool.GetBuffer(0); try { PacketIO.ReadPacketData(Header, stream, length, protocolID, key, tempBuffer); } catch { BufferPool.ReturnBuffer(tempBuffer); return(false); } return(true); }
public bool Read(ByteArrayReaderWriter stream, int length, byte[] key, ulong protocolID) { Payload = BufferPool.GetBuffer(2048); Length = 0; try { Length = PacketIO.ReadPacketData(Header, stream, length, protocolID, key, Payload); } catch { BufferPool.ReturnBuffer(Payload); return(false); } if (Length < 1 || Length > Defines.MAX_PAYLOAD_SIZE) { BufferPool.ReturnBuffer(Payload); return(false); } return(true); }