public static void SendShapes()
 {
     foreach (Drawable d in shapes)
     {
         MugicPacket p = d.GetUpdate();
         if (p != null)
         {
             MugicConnection.EnueuePacket(p);
         }
     }
     MugicConnection.SendUpdate();
 }
Example #2
0
 protected void InitPacket(MugicCommand s, MugicPacket p)
 {
     if (!wasCreated)
     {
         objectId = MugicObjectManager.NextId;
         p.Command(s, objectId);
         wasCreated = true;
     }
     else
     {
         p.Command(MugicCommand.Update, objectId);
     }
 }
Example #3
0
        private static void SendThreadedUpdate()
        {
            List <string> packets       = new List <string>();
            int           size          = 0;
            string        currentPacket = "";

            while (outgoing.Count > 0)
            {
                MugicPacket p      = outgoing.Dequeue();
                string      packet = p.ToString();

                int tempSize = size;
                tempSize += packet.Length;

                if (tempSize < Config.Max_Packet_Size)
                {
                    currentPacket += packet;
                    size          += packet.Length;
                }
                else
                {
                    packets.Add(currentPacket);
                    currentPacket  = "";
                    size           = 0;
                    currentPacket += packet;
                }
            }
            // Add any remainder
            packets.Add(currentPacket);

            foreach (String packet in packets)
            {
                byte[] encoded = Encoding.ASCII.GetBytes(packet);
                Console.Write(packet + "\n");
                sock.Send(encoded);
            }
        }
Example #4
0
        public override MugicPacket GetUpdate()
        {
            if(!dirty) return null;

            MugicPacket packet = new MugicPacket();

            base.InitPacket(MugicCommand.Rectangle, packet);

            packet.Parameter(MugicParam.X, position.X * Config.WallScalar);
            packet.Parameter(MugicParam.Y, position.Y * Config.WallScalar);
            packet.Parameter(MugicParam.Z, position.Z * Config.WallScalar);

            packet.Parameter(MugicParam.Width, bounds.width * Config.WallScalar);
            packet.Parameter(MugicParam.Height, bounds.height * Config.WallScalar);

            if (image != null)
            {
                packet.Parameter(MugicParam.Texture, image.Filename);
            }

            dirty = false;

            return packet;
        }
Example #5
0
 public static void EnueuePacket(MugicPacket p)
 {
     outgoing.Enqueue(p);
 }
 public static void EnueuePacket(MugicPacket p)
 {
     outgoing.Enqueue(p);
 }