Microsoft.Protocols.TestTools.StackSdk.RemoteDesktop.Rdpedyc.RdpedycServer.SendFirstCompressedDataPdu C# (CSharp) Méthode

SendFirstCompressedDataPdu() public méthode

public SendFirstCompressedDataPdu ( uint channelId, byte data ) : void
channelId uint
data byte
Résultat void
        public void SendFirstCompressedDataPdu(uint channelId, byte[] data)
        {
            if (data.Length < 1599-4)//Cmd:4 bits, Len: 2 bits, cbChid:2 bits, ChannelId: 8 bit, Length: no more than 1599, so it it 16 bits. Totally, 4 bytes
            {
                byte[] compressedData = pduBuilder.CompressDataToRdp8BulkEncodedData(data, PACKET_COMPR_FLAG.PACKET_COMPR_TYPE_LITE | PACKET_COMPR_FLAG.PACKET_COMPRESSED);
                DataFirstCompressedDvcPdu firstCompressedPdu = new DataFirstCompressedDvcPdu(channelId, (uint)data.Length, compressedData);
                firstCompressedPdu.GetNonDataSize();
                Send(firstCompressedPdu, DynamicVC_TransportType.RDP_UDP_Reliable);
            }
            else
            {
                //Cmd:4 bits, Len: 2 bits, cbChid:2 bits, ChannelId: 8 bit, Length: no more than 1599, so it it 16 bits. Totally, 4 bytes
                //So the max length of the data should be 1599-4
                byte[] uncompressedData = new byte[1595];
                Array.Copy(data, uncompressedData, 1599 - 4);
                byte[] compressedData = pduBuilder.CompressDataToRdp8BulkEncodedData(uncompressedData, PACKET_COMPR_FLAG.PACKET_COMPR_TYPE_LITE | PACKET_COMPR_FLAG.PACKET_COMPRESSED);

                DataFirstCompressedDvcPdu firstCompressedPdu = new DataFirstCompressedDvcPdu(channelId, (uint)data.Length, compressedData);
                firstCompressedPdu.GetNonDataSize();
                Send(firstCompressedPdu, DynamicVC_TransportType.RDP_UDP_Reliable);

                int leftBytes = uncompressedData.Length % 1595;
                int followingMsgCount = 0;

                if (leftBytes > 0)
                {
                    followingMsgCount = data.Length / 1595 + 1 - 1; //minus the FirstCompressedData
                    for (int i = 0; i < followingMsgCount; i++)
                    {
                        if (i != followingMsgCount)
                        {
                            byte[] followingUnCompressedData = new byte[1595];
                            Array.Copy(data, i * 1595, followingUnCompressedData, 0, 1595);
                            byte[] followingCompressedData = pduBuilder.CompressDataToRdp8BulkEncodedData(followingUnCompressedData, PACKET_COMPR_FLAG.PACKET_COMPR_TYPE_LITE | PACKET_COMPR_FLAG.PACKET_COMPRESSED);

                            DynamicVCPDU followingCompressedPDU = pduBuilder.CreateDataCompressedReqPdu(channelId, followingCompressedData);
                            Send(followingCompressedPDU, DynamicVC_TransportType.RDP_UDP_Reliable);
                        }
                        else //Last message
                        {
                            byte[] lastUnCompressedData = new byte[data.Length - i * 1595];
                            Array.Copy(data, i * 1595, lastUnCompressedData, 0, data.Length - i * 1595);
                            byte[] lastCompressedData = pduBuilder.CompressDataToRdp8BulkEncodedData(lastUnCompressedData, PACKET_COMPR_FLAG.PACKET_COMPR_TYPE_LITE | PACKET_COMPR_FLAG.PACKET_COMPRESSED);

                            DynamicVCPDU followingPdu = pduBuilder.CreateDataCompressedReqPdu(channelId, lastCompressedData);
                            Send(followingPdu, DynamicVC_TransportType.RDP_UDP_Reliable);
                        }
                    }
                }
            }
        }