So you want a queued broadcast? Like after 10 seconds (or more) if a message is pending, the next message gets appended to (sent)? If so...
Code:
//requires
//using System.Threading;
//using System.Collections.Generic;
// call BroadcastQueue.Init() when the server starts up
public class BroadcastQueue
{
private static Queue<byte[]> Queue;
private static void ExportGlobalPacket(byte[] Packet)
{
// method to send the packet to everyone on the server
}
public static void Init()
{
Queue = new Queue<byte[]>();
new Thread(
delegate()
{
while (true)
{
const int Ten_Seconds = 10 * 1000;
byte[] Outgoing;
lock (Queue)
{
Outgoing = Queue.Dequeue();
}
ExportGlobalPacket(Outgoing);
Thread.Sleep(Ten_Seconds);
}
}
).Start();
}
public static void Add(byte[] BroadcastMsgPacket)
{
lock (Queue)
{
Queue.Enqueue(BroadcastMsgPacket);
}
}
}