public virtual int GetReceiveLimit() { return(mRecordLayer.GetReceiveLimit()); }
internal Message ReceiveMessage() { if (mSending) { mSending = false; PrepareInboundFlight(); } DtlsReassembler dtlsReassembler = (DtlsReassembler)mCurrentInboundFlight.get_Item((object)mNextReceiveSeq); if (dtlsReassembler != null) { byte[] bodyIfComplete = dtlsReassembler.GetBodyIfComplete(); if (bodyIfComplete != null) { mPreviousInboundFlight = null; return(UpdateHandshakeMessagesDigest(new Message(mNextReceiveSeq++, dtlsReassembler.MsgType, bodyIfComplete))); } } byte[] array = null; int num = 1000; while (true) { int receiveLimit = mRecordLayer.GetReceiveLimit(); if (array == null || array.Length < receiveLimit) { array = new byte[receiveLimit]; } try { while (true) { int num2 = mRecordLayer.Receive(array, 0, receiveLimit, num); if (num2 < 0) { break; } if (num2 < 12) { continue; } int num3 = TlsUtilities.ReadUint24(array, 9); if (num2 != num3 + 12) { continue; } int num4 = TlsUtilities.ReadUint16(array, 4); if (num4 > mNextReceiveSeq + 10) { continue; } byte msg_type = TlsUtilities.ReadUint8(array, 0); int num5 = TlsUtilities.ReadUint24(array, 1); int num6 = TlsUtilities.ReadUint24(array, 6); if (num6 + num3 > num5) { continue; } if (num4 < mNextReceiveSeq) { if (mPreviousInboundFlight == null) { continue; } DtlsReassembler dtlsReassembler2 = (DtlsReassembler)mPreviousInboundFlight.get_Item((object)num4); if (dtlsReassembler2 != null) { dtlsReassembler2.ContributeFragment(msg_type, num5, array, 12, num6, num3); if (CheckAll(mPreviousInboundFlight)) { ResendOutboundFlight(); num = Math.Min(num * 2, 60000); ResetAll(mPreviousInboundFlight); } } continue; } DtlsReassembler dtlsReassembler3 = (DtlsReassembler)mCurrentInboundFlight.get_Item((object)num4); if (dtlsReassembler3 == null) { dtlsReassembler3 = new DtlsReassembler(msg_type, num5); mCurrentInboundFlight.set_Item((object)num4, (object)dtlsReassembler3); } dtlsReassembler3.ContributeFragment(msg_type, num5, array, 12, num6, num3); if (num4 == mNextReceiveSeq) { byte[] bodyIfComplete2 = dtlsReassembler3.GetBodyIfComplete(); if (bodyIfComplete2 != null) { mPreviousInboundFlight = null; return(UpdateHandshakeMessagesDigest(new Message(mNextReceiveSeq++, dtlsReassembler3.MsgType, bodyIfComplete2))); } } } } catch (IOException) { } ResendOutboundFlight(); num = Math.Min(num * 2, 60000); } }