<commit_before>﻿using System;
using System.Collections.Generic;
using Terraria.ModLoader;
using HamstarHelpers.Classes.Loadable;


namespace HamstarHelpers.Services.Network.Scraper {
	/// <summary>
	/// Implements a rudimentary network scraper.
	/// 
	/// Note: As of yet, outgoing byte data is not yet captured; only `NetMessage.SendData(...)` parameter values.
	/// </summary>
	public partial class Scraper : ILoadable {
		/// <summary></summary>
		public static bool IsScrappingSentData = false;

		/// <summary></summary>
		public static bool IsScrappingReceivedData = false;


		////////////////

		/// <summary></summary>
		public static IReadOnlyList<ScrapedSentData> SentDataView
			=> ModContent.GetInstance<Scraper>().SentData.AsReadOnly();

		/// <summary></summary>
		public static IReadOnlyList<ScrapedReceivedData> ReceivedDataView
			=> ModContent.GetInstance<Scraper>().ReceivedData.AsReadOnly();



		////////////////

		/// <summary></summary>
		/// <param name="listener"></param>
		public static void AddSendDataListener( Action<ScrapedSentData> listener ) {
			var scraper = ModContent.GetInstance<Scraper>();
			scraper.OnSent.Add( listener );
		}

		/// <summary></summary>
		/// <param name="listener"></param>
		public static void AddReceiveDataListener( Action<ScrapedReceivedData> listener ) {
			var scraper = ModContent.GetInstance<Scraper>();
			scraper.OnReceived.Add( listener );
		}
	}
}<commit_msg>v5.11.0 - Added listener removers to Scraper API<commit_after>﻿using System;
using System.Collections.Generic;
using Terraria.ModLoader;
using HamstarHelpers.Classes.Loadable;


namespace HamstarHelpers.Services.Network.Scraper {
	/// <summary>
	/// Implements a rudimentary network scraper.
	/// 
	/// Note: As of yet, outgoing byte data is not yet captured; only `NetMessage.SendData(...)` parameter values.
	/// </summary>
	public partial class Scraper : ILoadable {
		/// <summary></summary>
		public static bool IsScrappingSentData = false;

		/// <summary></summary>
		public static bool IsScrappingReceivedData = false;


		////////////////

		/// <summary></summary>
		public static IReadOnlyList<ScrapedSentData> SentDataView
			=> ModContent.GetInstance<Scraper>().SentData.AsReadOnly();

		/// <summary></summary>
		public static IReadOnlyList<ScrapedReceivedData> ReceivedDataView
			=> ModContent.GetInstance<Scraper>().ReceivedData.AsReadOnly();



		////////////////

		/// <summary></summary>
		/// <param name="listener"></param>
		public static void AddSendDataListener( Action<ScrapedSentData> listener ) {
			var scraper = ModContent.GetInstance<Scraper>();
			scraper.OnSent.Add( listener );
		}

		/// <summary></summary>
		/// <param name="listener"></param>
		public static void AddReceiveDataListener( Action<ScrapedReceivedData> listener ) {
			var scraper = ModContent.GetInstance<Scraper>();
			scraper.OnReceived.Add( listener );
		}


		/// <summary></summary>
		/// <param name="listener"></param>
		public static bool RemoveSendDataListener( Action<ScrapedSentData> listener ) {
			var scraper = ModContent.GetInstance<Scraper>();
			return scraper.OnSent.Remove( listener );
		}

		/// <summary></summary>
		/// <param name="listener"></param>
		public static bool RemoveReceiveDataListener( Action<ScrapedReceivedData> listener ) {
			var scraper = ModContent.GetInstance<Scraper>();
			return scraper.OnReceived.Remove( listener );
		}
	}
}
{'fraction_non_alphanumeric': 0.15409451130026416, 'fraction_numerical': 0.001174053419430584, 'mean_word_length': 3.7865168539325844, 'pattern_counts': {'":': 0, '<': 67, '<?xml version=': 0, '>': 71, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5624421', 'n_tokens_mistral': 1105, 'n_tokens_neox': 1005, 'n_words': 214}