コード例 #1
0
        public ConnectionHandler(IMudMessage mudMessage)
        {
            ContinueRunning = true;
            TcpClient   clientSocket = default(TcpClient);
            TcpListener serverSocket = new TcpListener(IPAddress.Any, GlobalReference.GlobalValues.Settings.Port);

            serverSocket.Start();

            while (ContinueRunning)
            {
                clientSocket = serverSocket.AcceptTcpClient();
                LogConnection(clientSocket);
                clientSocket.ReceiveBufferSize = (int)Math.Pow(2, 20);
                clientSocket.SendBufferSize    = clientSocket.ReceiveBufferSize;
                ServerHandler serverHandler = new ServerHandler(clientSocket, mudMessage);
            }

            clientSocket.Close();
            serverSocket.Stop();

            if (GlobalReference.GlobalValues.Settings.UseCachingFileIO)
            {
                ICachedFileIO cachedFileIO = GlobalReference.GlobalValues.FileIO as ICachedFileIO;
                cachedFileIO.Flush();
            }
        }
コード例 #2
0
ファイル: World.cs プロジェクト: elavanis/Mud
        public void PerformTick()
        {
            lock (_tickPadlock)
            {
                PerformCombatTick();
                PutPlayersIntoWorld();
                UpdateWeather();
                ReloadZones();
                UpdatePerformanceCounters();
                AutoSaveCharacters();

#if DEBUG
                foreach (IZone zone in Zones.Values)
                {
                    ProcessRooms(zone);
                }
#else
                Parallel.ForEach(_zonePartitioner, (range, loopState) =>
                {
                    // Loop over each range element without a delegate invocation.
                    for (int i = range.Item1; i < range.Item2; i++)
                    {
                        IZone zone = _zones[i];
                        ProcessRooms(zone);
                    }
                });
#endif

                CatchPlayersOutSideOfTheWorldDueToReloadedZones();

                NotifyPrecipitation = false;
                NotifyWindSpeed     = false;

                ProcessSerialCommands();

                DoWorldCommands();

                GlobalReference.GlobalValues.Logger.FlushLogs();

                //only flush logs every 5 minutes
                if (GlobalReference.GlobalValues.Settings.UseCachingFileIO &&
                    GlobalReference.GlobalValues.TickCounter % 600 == 0)
                {
                    ICachedFileIO cachedFileIO = GlobalReference.GlobalValues.FileIO as ICachedFileIO;
                    cachedFileIO.Flush();
                }
            }
        }