private RdpbcgrSlowPathUpdatePdu[] ParseSlowPathUpdates(byte[] data, ref int currentIndex)
{
// A list of slow-path update PDUs
List<RdpbcgrSlowPathUpdatePdu> listPdu = new List<RdpbcgrSlowPathUpdatePdu>();
// Parse one by one
while (currentIndex < data.Length)
{
// Get pduType2 and updateType
TS_SHAREDATAHEADER shareDataHeader = ParseTsShareDataHeader(data, ref currentIndex);
// Get update data
int updateDataLength = shareDataHeader.shareControlHeader.totalLength
- Marshal.SizeOf(shareDataHeader);
byte[] updateData = GetBytes(data, ref currentIndex, updateDataLength);
// Decompress update data if needed
updateData = clientContext.Decompress(updateData, shareDataHeader.compressedType);
// Get a Slow-Path Update PDU
RdpbcgrSlowPathUpdatePdu pdu = null;
if (pduType2_Values.PDUTYPE2_UPDATE == shareDataHeader.pduType2)
{
// Slow-Path Graphics Update PDU
pdu = ParseTsGraphicsUpdatePdu(updateData, shareDataHeader);
listPdu.Add(pdu);
}
else if (pduType2_Values.PDUTYPE2_POINTER == shareDataHeader.pduType2)
{
// Slow-Path Pointer Update PDU
pdu = ParseTsPointerPdu(updateData, shareDataHeader);
listPdu.Add(pdu);
}
else
{
throw new FormatException(ConstValue.ERROR_MESSAGE_ENUM_UNRECOGNIZED);
}
}
// Copy list to array
RdpbcgrSlowPathUpdatePdu[] arrayPdu = new RdpbcgrSlowPathUpdatePdu[listPdu.Count];
for (int i = 0; i < arrayPdu.Length; i++)
{
arrayPdu[i] = listPdu[i];
}
return arrayPdu;
}