<commit_before>﻿using Lidgren.Network;
using LunaCommon.Message;
using Server.Client;
using Server.Lidgren;
using Server.Settings;
using System;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.IO;
using System.Net;

namespace Server.Context
{
    public static class ServerContext
    {
        public static ConcurrentDictionary<IPEndPoint, ClientStructure> Clients { get; set; } =
            new ConcurrentDictionary<IPEndPoint, ClientStructure>();

        public static bool ServerRunning { get; set; }
        public static bool ServerStarting { get; set; }
        public static Stopwatch ServerClock { get; } = new Stopwatch();
        public static long StartTime { get; set; }
        public static string ModFilePath { get; } = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "LMPModControl.txt");
        public static int PlayerCount => ClientRetriever.GetActiveClientCount();
        public static string UniverseDirectory { get; } = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Universe");
        public static string ConfigDirectory { get; } = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config");
        public static string Players { get; } = ClientRetriever.GetActivePlayerNames();
        public static int Day { get; set; }
        public static long LastPlayerActivity { get; set; }

        // Configuration object
        public static NetPeerConfiguration Config { get; } = new NetPeerConfiguration("LMP")
        {
            AutoFlushSendQueue = false,
            SendBufferSize = 500000, //500kb
            ReceiveBufferSize = 500000, //500kb
            //Set it to false so lidgren doesn't wait until msg.size = MTU for sending
            Port = GeneralSettings.SettingsStore.Port,
            MaximumConnections = GeneralSettings.SettingsStore.MaxPlayers,
            SuppressUnreliableUnorderedAcks = true,
            PingInterval = GeneralSettings.SettingsStore.HearbeatMsInterval,
            ConnectionTimeout = (float)TimeSpan.FromMilliseconds(GeneralSettings.SettingsStore.ConnectionMsTimeout).TotalSeconds
        };

        public static LidgrenServer LidgrenServer { get; } = new LidgrenServer();
        public static MasterServerMessageFactory MasterServerMessageFactory { get; } = new MasterServerMessageFactory();

        public static ServerMessageFactory ServerMessageFactory { get; } = new ServerMessageFactory();
        public static ClientMessageFactory ClientMessageFactory { get; } = new ClientMessageFactory();
    }
}<commit_msg>Fix heartbeat interval<commit_after>﻿using Lidgren.Network;
using LunaCommon.Message;
using Server.Client;
using Server.Lidgren;
using Server.Settings;
using System;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.IO;
using System.Net;

namespace Server.Context
{
    public static class ServerContext
    {
        public static ConcurrentDictionary<IPEndPoint, ClientStructure> Clients { get; set; } =
            new ConcurrentDictionary<IPEndPoint, ClientStructure>();

        public static bool ServerRunning { get; set; }
        public static bool ServerStarting { get; set; }
        public static Stopwatch ServerClock { get; } = new Stopwatch();
        public static long StartTime { get; set; }
        public static string ModFilePath { get; } = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "LMPModControl.txt");
        public static int PlayerCount => ClientRetriever.GetActiveClientCount();
        public static string UniverseDirectory { get; } = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Universe");
        public static string ConfigDirectory { get; } = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config");
        public static string Players { get; } = ClientRetriever.GetActivePlayerNames();
        public static int Day { get; set; }
        public static long LastPlayerActivity { get; set; }

        // Configuration object
        public static NetPeerConfiguration Config { get; } = new NetPeerConfiguration("LMP")
        {
            AutoFlushSendQueue = false,
            SendBufferSize = 500000, //500kb
            ReceiveBufferSize = 500000, //500kb
            //Set it to false so lidgren doesn't wait until msg.size = MTU for sending
            Port = GeneralSettings.SettingsStore.Port,
            MaximumConnections = GeneralSettings.SettingsStore.MaxPlayers,
            SuppressUnreliableUnorderedAcks = true,
            PingInterval = (float)TimeSpan.FromMilliseconds(GeneralSettings.SettingsStore.HearbeatMsInterval).TotalSeconds,
            ConnectionTimeout = (float)TimeSpan.FromMilliseconds(GeneralSettings.SettingsStore.ConnectionMsTimeout).TotalSeconds
        };

        public static LidgrenServer LidgrenServer { get; } = new LidgrenServer();
        public static MasterServerMessageFactory MasterServerMessageFactory { get; } = new MasterServerMessageFactory();

        public static ServerMessageFactory ServerMessageFactory { get; } = new ServerMessageFactory();
        public static ClientMessageFactory ClientMessageFactory { get; } = new ClientMessageFactory();
    }
}
{'fraction_non_alphanumeric': 0.08018684312962242, 'fraction_numerical': 0.0070066173608407945, 'mean_word_length': 3.4803836094158673, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '221216', 'n_tokens_mistral': 1289, 'n_tokens_neox': 1232, 'n_words': 348}