using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading.Tasks;
using skyscraper5.Skyscraper.Plugins;
using skyscraper5.Skyscraper.Scraper;
using skyscraper5.Skyscraper.Scraper.StreamAutodetection;

namespace skyscraper8.Ietf.Rfc4236_ULE
{
	[SkyscraperPlugin]
	internal class UleContestant : Contestant, UleEventHandler
	{
		public UleContestant(int pid) : base("ULE", pid)
		{
			PacketProcessor = new UlePacketProcessor(pid, this);
		}

		public override void Dispose()
		{

		}

		public override void DeclareWinner(SkyscraperContext skyscraperContext, int pid, ProgramContext programContext)
		{
			skyscraperContext.DvbContext.RegisterPacketProcessor(pid, new UlePacketProcessor(pid, skyscraperContext));
		}

		public override void Introduce(ProgramContext programContext)
		{

		}
		
		public void OnEthernetFrame(int pid, PhysicalAddress destination, PhysicalAddress source, ushort etherType, byte[] contents)
		{
			Score++;
		}

		public void OnUleError(int pid, int errorNo)
		{
			Score--;
		}
	}
}
