Ejemplo n.º 1
0
        public Bitmap ReceiveImage()
        {
            int      receivedPackages = 0;
            ImageBit image            = Deserialize(client.Receive());

            ImageBit[] arrStructs = new ImageBit[image.NumberBits];
            arrStructs[image.CurrentBit] = image;
            int imageNumber = image.ImageNumber;

            receivedPackages++;
            while (true)
            {
                image = Deserialize(client.Receive());
                if (imageNumber == image.ImageNumber)
                {
                    receivedPackages++;
                    arrStructs[image.CurrentBit] = image;
                    if ((receivedPackages == (image.NumberBits)) && (imageNumber == image.ImageNumber))
                    {
                        client.SendResponse(response);
                        return(AssemblyBitmap(arrStructs, image.Size));
                    }
                }
                else
                {
                    imageNumber = image.ImageNumber;
                    arrStructs  = new ImageBit[image.NumberBits];
                    arrStructs[image.CurrentBit] = image;
                    receivedPackages             = 1;
                }
            }
        }
Ejemplo n.º 2
0
 public string ReceiveMessages()
 {
     byte[] message = udp.Receive();
     return(Encoding.UTF8.GetString(message));
 }
Ejemplo n.º 3
0
 /// <summary>
 ///     Called when the session needs to be updated. This should be called regularly (in each game's Update) to ensure
 ///     proper flow of network traffic.
 /// </summary>
 public virtual void Update()
 {
     // Drive UDP network.
     Udp.Receive();
 }