mirror of
https://github.com/sebastian-heinz/Arrowgene.DragonsDogmaOnline
synced 2026-08-03 11:12:41 -04:00
36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
using Arrowgene.Ddon.Shared.Entity;
|
|
using Arrowgene.Ddon.Shared.Network;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace Arrowgene.Ddon.Server.Network
|
|
{
|
|
public class PacketQueue : Queue<(Client Client, Packet Packet)>
|
|
{
|
|
public PacketQueue() : base() { }
|
|
public PacketQueue(IEnumerable<(Client Client, Packet Packet)> collection) : base(collection) { }
|
|
public void Send()
|
|
{
|
|
while (this.Any())
|
|
{
|
|
(var client, var packet) = this.Dequeue();
|
|
client.Send(packet);
|
|
}
|
|
}
|
|
|
|
public void Enqueue<TResStruct>(Client client, TResStruct res)
|
|
where TResStruct : class, IPacketStructure, new()
|
|
{
|
|
StructurePacket<TResStruct> packet = new StructurePacket<TResStruct>(res);
|
|
this.Enqueue((client, packet));
|
|
}
|
|
|
|
public void AddRange(IEnumerable<(Client Client, Packet Packet)> other)
|
|
{
|
|
foreach(var item in other)
|
|
{
|
|
this.Enqueue(item);
|
|
}
|
|
}
|
|
}
|
|
}
|