<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net.Sockets;

namespace Buildstation_Client2.Class
{
    static class NetworkThread
    {
        /// <summary>
        /// Sorts data incoming from the server and acts apon it.
        /// </summary>
        public static void NetworkSortThread()
        {
            // Setting up everything needed for Sending and reciving data.
            TcpClient Client = new TcpClient(Variables.ServerIP, Variables.ServerPort);
            StreamReader ServerGet = new StreamReader(Client.GetStream());
            StreamWriter ServerSend = new StreamWriter(Client.GetStream());
            string Data;
            string[] DataSeperated;
            try
            {
                ServerSend.WriteLine("Info;Connected");  // Tells the server it's connected, and to send it to the info NetworkSorter. It works in the format [Thread];[Data]. If there is more than 1 peace of data, it can be seperated by commas.
                ServerSend.Flush();

                while (true)
                {
                    Data = ServerGet.ReadLine();
                    DataSeperated = Data.Split(';');

                    if (Data == "Sorter;Disconnect")    // Perhaps not nesasary, but I'm doing it anyway.
                    {
                        Client.Close();
                        break;
                    }

                    NetworkSorters[DataSeperated[0]].NewTrafic(DataSeperated[1]);      // Tells the NetworkSorter that it has new network trafic and gives it the data related to it.
                }
            }
            catch (Exception)
            {
                Game1.ExitGame();
            }
        }

        private static Dictionary<string, dynamic> NetworkSorters = new Dictionary<string, dynamic>();

        /// <summary>
        /// Allows you to recive network trafic.
        /// </summary>
        /// <param name="SorterName">The name trafic will refer to you as.</param>
        /// <param name="NetworkSorter">The reference to you. The best way to do this is to use the keyword "this" by itself.</param>
        public static void RegisterSorter(string SorterName, dynamic NetworkSorter)
        {
            NetworkSorters.Add(SorterName, NetworkSorter);
        }

        /// <summary>
        /// Send a packet to the server.
        /// </summary>
        /// <param name="NetworkSorter">The sorter the data will go to.</param>
        /// <param name="Data">The data sent to the server. Normally comma seperated values with no spaces.</param>
        public static void SendMessage(string NetworkSorter, string Data)
        {<commit_msg>Forgot a file to commit<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Net.Sockets;

namespace Buildstation_Client2.Class
{
    static class NetworkThread
    {
        /// <summary>
        /// Sorts data incoming from the server and acts apon it.
        /// </summary>
        public static void NetworkSortThread()
        {
            // Setting up everything needed for Sending and reciving data.
            TcpClient Client = new TcpClient(Variables.ServerIP, Variables.ServerPort);
            StreamReader ServerGet = new StreamReader(Client.GetStream());
            StreamWriter ServerSend = new StreamWriter(Client.GetStream());
            string Data;
            string[] DataSeperated;
            try
            {
                ServerSend.WriteLine("Info;Connected");  // Tells the server it's connected, and to send it to the info NetworkSorter. It works in the format [Thread];[Data]. If there is more than 1 peace of data, it can be seperated by commas.
                ServerSend.Flush();

                while (true)
                {
                    Data = ServerGet.ReadLine();
                    DataSeperated = Data.Split(';');

                    if (Data == "Sorter;Disconnect")    // Perhaps not nesasary, but I'm doing it anyway.
                    {
                        Client.Close();
                        break;
                    }

                    Console.WriteLine("Recived packet of sorter " + DataSeperated[0] + " And data " + DataSeperated[1]);

                    NetworkSorters[DataSeperated[0]].NewTrafic(DataSeperated[1]);      // Tells the NetworkSorter that it has new network trafic and gives it the data related to it.
                }
            }
            catch (Exception)
            {
                Game1.ExitGame();
            }
        }

        private static Dictionary<string, dynamic> NetworkSorters = new Dictionary<string, dynamic>();

        /// <summary>
        /// Allows you to recive network trafic.
        /// </summary>
        /// <param name="SorterName">The name trafic will refer to you as.</param>
        /// <param name="NetworkSorter">The reference to you. The best way to do this is to use the keyword "this" by itself.</param>
        public static void RegisterSorter(string SorterName, dynamic NetworkSorter)
        {
            NetworkSorters.Add(SorterName, NetworkSorter);
        }

        /// <summary>
        /// Send a packet to the server.
        /// </summary>
        /// <param name="NetworkSorter">The sorter the data will go to.</param>
        /// <param name="Data">The data sent to the server. Normally comma seperated values with no spaces.</param>
        public static void SendMessage(string NetworkSorter, string Data)
        {
{'fraction_non_alphanumeric': 0.09451219512195122, 'fraction_numerical': 0.002152080344332855, 'mean_word_length': 1.8067438349270257, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 35, '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': '6960253', 'n_tokens_mistral': 1423, 'n_tokens_neox': 1369, 'n_words': 464}