public static void SendShapes() { foreach (Drawable d in shapes) { MugicPacket p = d.GetUpdate(); if (p != null) { MugicConnection.EnueuePacket(p); } } MugicConnection.SendUpdate(); }
protected void InitPacket(MugicCommand s, MugicPacket p) { if (!wasCreated) { objectId = MugicObjectManager.NextId; p.Command(s, objectId); wasCreated = true; } else { p.Command(MugicCommand.Update, objectId); } }
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); } }
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; }
public static void EnueuePacket(MugicPacket p) { outgoing.Enqueue(p); }