PacketPrioritizer.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using libsecondlife.Packets;
  2. using System.Collections.Generic;
  3. using OpenSim.Framework;
  4. namespace OpenSim.Region.ClientStack
  5. {
  6. public class PacketPrioritizer
  7. {
  8. private Dictionary<PacketType, int> Priorities;
  9. public PacketPrioritizer()
  10. {
  11. Priorities = new Dictionary<PacketType, int>();
  12. //High priority packets
  13. /*Priorities[PacketType.StartPingCheck] = 60000;
  14. Priorities[PacketType.PacketAck] = 60000;*/
  15. //Very low priority packets
  16. Priorities[PacketType.ObjectImage] = 1;
  17. Priorities[PacketType.ImageData] = 1;
  18. Priorities[PacketType.ImagePacket] = 1;
  19. }
  20. public void Bind(PrioritizedQueue<QueItem> queue)
  21. {
  22. queue.PriorityDeterminer = new PrioritizedQueue<QueItem>.DeterminePriorityDelegate(this.DeterminePriority);
  23. }
  24. public int DeterminePriority(QueItem item)
  25. {
  26. Packet packet = item.Packet;
  27. if (Priorities.ContainsKey(packet.Type))
  28. return Priorities[packet.Type];
  29. //Default priority is 20
  30. return 50;
  31. }
  32. }
  33. }