Microsoft.Protocols.TestTools.StackSdk.RemoteDesktop.Rdpbcgr.RdpbcgrServerDecoder.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 ) : Microsoft.Protocols.TestTools.StackSdk.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 Microsoft.Protocols.TestTools.StackSdk.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;

            for (int i = 0; i < server.ServerContext.SessionContexts.Count; i++)
            {
                if (endPoint == server.ServerContext.SessionContexts[i].Identity)
                {
                    try
                    {
                        // ETW Provider Dump Message
                        string messageName;
                        if (ConstValue.SLOW_PATH_PDU_INDICATOR_VALUE == packetData[ConstValue.SLOW_PATH_PDU_INDICATOR_INDEX])
                        {
                            // Slow-Path
                            messageName = "RDPBCGR:ReceivedSlowPathPDU";
                        }
                        else
                        {
                            // Fast-Path
                            messageName = "RDPBCGR:ReceivedFastPathPDU";
                        }
                        ExtendedLogger.DumpMessage(messageName, RdpbcgrUtility.DumpLevel_Layer0, "Received Original RDPBCGR Message", packetData);

                        pdu = DecodePdu(server.ServerContext.SessionContexts[i], packetData);
                    }
                    catch (FormatException e)
                    {
                        pdu = new ErrorPdu(e, packetData);
                    }

                    // Update client context and client
                    server.ServerContext.SessionContexts[i].UpdateContext(pdu);
                    server.CheckDecryptionCount(server.ServerContext.SessionContexts[i]);

                    break;
                }
                else
                {
                    pdu = null;
                }
            }
            return new StackPacket[] { pdu };
        }
RdpbcgrServerDecoder