Microsoft.Protocols.TestTools.StackSdk.RemoteDesktop.Rdpbcgr.RdpbcgrDecoder.DecodePacketCallback C# (CSharp) Method

DecodePacketCallback() private method

Decode RDPBCGR PDUs from the received message bytes
private DecodePacketCallback ( object endPoint, byte receivedBytes, int &consumedLength, int &expectedLength ) : StackPacket[]
endPoint object the endpoint from which the message bytes are received.
receivedBytes byte the received message bytes to be decoded.
consumedLength int the length of message bytes consumed by decoder.
expectedLength int the length of message bytes the decoder expects to receive.
return StackPacket[]
        internal StackPacket[] DecodePacketCallback(
            object endPoint,
            byte[] receivedBytes,
            out int consumedLength,
            out int expectedLength)
        {
            StackPacket pdu = null;
            expectedLength = 0;

            // Get bytes for only one packet
            byte[] packetData = GetPacket(receivedBytes);
            if (null == packetData)
            {
                // Received bytes does not contain enough data
                consumedLength = 0;
                return null;
            }
            consumedLength = packetData.Length;

            // Decode PDU
            try
            {
                pdu = DecodePdu(packetData);
                if (pdu.GetType() == typeof(Server_X_224_Connection_Confirm_Pdu))
                {
                    // Negotiation-based security-enhanced Connection
                    client.UpdateTransport();
                }
            }
            catch (FormatException e)
            {
                pdu = new ErrorPdu(e);
            }

            // Update client context and client
            clientContext.UpdateContext(pdu);
            client.CheckDecryptionCount();
            return new StackPacket[] { pdu };
        }
RdpbcgrDecoder