<commit_before>﻿using System;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Ships_Common;
using Ships_Common.Net;
using Ships_Server.Handlers;
using Ships_Server.Rooms;
using SocketLib;

namespace Ships_Server {
    
    public struct Packet<T> {
        public RoomManager roomManager;
        public Client client;
        public T data;

        public Packet(RoomManager roomManager, Client client, T data) {
            this.roomManager = roomManager;
            this.client = client;
            this.data = data;
        }
    }
    
    internal class Program {
        
        private static ServerSocket server;
        private static RoomManager rooms;
        public static EventSystem<Packet<string[]>> eventSystem;
        
        public static void Main(string[] args) {
            eventSystem = new EventSystem<Packet<string[]>>();
            Server.Init();
            
            new Task (() => {
                while (true) {
                    string line = Console.ReadLine();
                    if (line == "close" || line == "exit") {
                        server.close();
                        return;
                    }
                    if (line == "test")
                        Console.WriteLine(Ship.defaultShips["SHIP_HUGE"].Instantiate(new Vector2(10, 10)));
                }
            }).Start();
            
            rooms = new RoomManager();
            server = new ServerSocket(8080);
            
            server.OnClientConnected += client => {
                
                client.send(Encoding.ASCII.GetBytes("ig~00000000"));
                Console.WriteLine("Client connected");
                
                client.OnMessage += message => {
                    string[] packet = PacketUtils.readPacket(Encoding.ASCII.GetBytes(message));
                    
                    Console.WriteLine("Received => " + message);
                    
                    eventSystem.Invoke(packet[0], new Packet<string[]>(rooms, client, packet.Skip(1).Take(packet.Length - 1).ToArray()));
                };
            };
            server.OnClientDisconnect += client => Console.WriteLine("Client disconnect");
            server.start();
        }
    }
}<commit_msg>INtegrated networking debug to the server code<commit_after>﻿using System;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Ships_Common;
using Ships_Common.Net;
using Ships_Server.Handlers;
using Ships_Server.Rooms;
using SocketLib;

namespace Ships_Server {
    
    public struct Packet<T> {
        public RoomManager roomManager;
        public Client client;
        public T data;

        public Packet(RoomManager roomManager, Client client, T data) {
            this.roomManager = roomManager;
            this.client = client;
            this.data = data;
        }
    }
    
    internal class Program {
        
        private static ServerSocket server;
        private static RoomManager rooms;
        public static EventSystem<Packet<string[]>> eventSystem;
        
        public static void Main(string[] args) {
            eventSystem = new EventSystem<Packet<string[]>>();
            Server.Init();
            
            new Task (() => {
                while (true) {
                    var readLine = Console.ReadLine();
                    if (readLine == null)
                        continue;
                        
                    string[] command = readLine.Split(' ');
                    if (command[0] == "close" || command[0] == "exit") {
                        server.close();
                        return;
                    }

                    if (command[0] == "netDebug") {
                        server.clients.ForEach(client => {
                            bool enable = bool.Parse(command[1]);
                            if (enable && !client.debugEnabled)
                                client.enableDebug();
                            else if (!enable && client.debugEnabled)
                                client.disableDebug();
                        });
                    }
                }
            }).Start();
            
            rooms = new RoomManager();
            server = new ServerSocket(8080);
            
            server.OnClientConnected += client => {
                
                client.send(Encoding.ASCII.GetBytes("ig~00000000"));
                Console.WriteLine("Client connected");
                
                client.OnMessage += message => {
                    string[] packet = PacketUtils.readPacket(Encoding.ASCII.GetBytes(message));
                    
                    Console.WriteLine("Received => " + message);
                    
                    eventSystem.Invoke(packet[0], new Packet<string[]>(rooms, client, packet.Skip(1).Take(packet.Length - 1).ToArray()));
                };
            };
            server.OnClientDisconnect += client => Console.WriteLine("Client disconnect");
            server.start();
        }
    }
}
{'fraction_non_alphanumeric': 0.1023063276167948, 'fraction_numerical': 0.00768775872264932, 'mean_word_length': 1.3866415804327374, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '5795292', 'n_tokens_mistral': 1237, 'n_tokens_neox': 1158, 'n_words': 261}