GetHeaderSize() public static method

public static GetHeaderSize ( ) : int
return int
示例#1
0
        public void BitmapAcquiredCBHandler(Bitmap aNewBitmap)
        {
            byte[] newBA  = aCodecUtility.CompressBmpToJPEGArray(aImageQuality, aNewBitmap);
            int    FileID = aRandomGenerator.Next();

            //Total size of the packet to send including header  +  data.
            PacketPartitionner pp = new PacketPartitionner(FileID, newBA.Length, Packet.GetHeaderSize() + Packet.DEFAULT_PACKET_SIZE, null);

            pp.PartitionFile(newBA, newBA.Length);

            //Console.WriteLine("Partition File ID " + FileID + " In " + pp.GetPartitionnedPackets().Count + " Packets");

            //Remove prints to the console
            for (int i = 0; i < pp.GetPartitionnedPackets().Count; i++)
            {
                Packet p = ((Packet)(pp.GetPartitionnedPackets()[i]));

                //Console.WriteLine("Send Packet:"+i);

                byte[] SerializedPacket = p.GetBytes();

                //Sending the data to a blocking queue that gets process by a thread generate additionnal delay
                //The best solution to reduce the lag for now is to send the data directly with SendNow method.
                //aUDPSender.SendDataUDP(SerializedPacket, SerializedPacket.Length);

                aUDPSender.SendBytesNow(SerializedPacket, SerializedPacket.Length);
            }

            pp.GetPartitionnedPackets().Clear();
        }
        //Handles the reception of 1 UDP packet of data.
        public void ReceivedHandler(int NumberOfAvailableData)
        {
            int PacketSize = Packet.GetHeaderSize() + Packet.DEFAULT_PACKET_SIZE;

            if (NumberOfAvailableData >= PacketSize)
            {
                while (aUDPListener.GetNumberOfReceivedData() >= PacketSize)
                {
                    byte[] buffer = new byte[PacketSize];

                    aUDPListener.ReceiveData(ref buffer, PacketSize);

                    Packet p = new Packet(buffer);

                    PacketReconstructors.ReconstructFile(p);
                }
            }
        }