当前位置: 首页>>代码示例>>C#>>正文


C# Server.Process方法代码示例

本文整理汇总了C#中Server.Process方法的典型用法代码示例。如果您正苦于以下问题:C# Server.Process方法的具体用法?C# Server.Process怎么用?C# Server.Process使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Server的用法示例。


在下文中一共展示了Server.Process方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ServerThreadStart

 public void ServerThreadStart()
 {
     try
     {
         Server server = new Server();
         server.SaveFilenameOverride = savefilename;
         server.exit = exit;
         DummyNetServer netServer = new DummyNetServer();
         netServer.SetPlatform(new GamePlatformNative());
         netServer.SetNetwork(dummyNetwork);
         server.mainSockets = new NetServer[3];
         server.mainSockets[0] = netServer;
         for (; ; )
         {
             server.Process();
             Thread.Sleep(1);
             platform.singlePlayerServerLoaded = true;
             if (exit != null && exit.GetExit()) { server.Stop(); break; }
             if (platform.singlepLayerServerExit)
             {
                 // Exit thread and reset shutdown variable
                 server.Exit();
                 platform.singlepLayerServerExit = false;
             }
         }
         exit.SetExit(false);
     }
     catch (Exception e)
     {
         MessageBox.Show(e.ToString());
     }
 }
开发者ID:Matthewism,项目名称:manicdigger,代码行数:32,代码来源:Program.cs

示例2: Start

        public void Start()
        {
            Server server = new Server();
            server.LoadConfig();
            var map = new ManicDiggerServer.ServerMap();
            map.d_CurrentTime = server;
            map.chunksize = 32;

            // TODO: make it possible to change the world generator at run-time!
            var generator = new NewWorldGenerator();
            generator.ChunkSize = map.chunksize;
            // apply chunk size to generator
            map.d_Generator = generator;
            server.chunksize = 32;

            map.d_Heightmap = new InfiniteMapChunked2d() { chunksize = server.chunksize, d_Map = map };
            map.Reset(server.config.MapSizeX, server.config.MapSizeY, server.config.MapSizeZ);
            server.d_Map = map;
            server.d_Generator = generator;
            string[] datapaths = new[] { Path.Combine(Path.Combine(Path.Combine("..", ".."), ".."), "data"), "data" };
            string[] datapathspublic = new[] { Path.Combine(datapaths[0], "public"), Path.Combine(datapaths[1], "public") };
            server.PublicDataPaths = datapathspublic;
            var getfile = new GetFileStream(datapaths);
            var data = new GameDataCsv();
            data.Load(MyStream.ReadAllLines(getfile.GetFile("blocks.csv")),
                MyStream.ReadAllLines(getfile.GetFile("defaultmaterialslots.csv")),
                MyStream.ReadAllLines(getfile.GetFile("lightlevels.csv")));
            var craftingrecipes = new CraftingRecipes();
            craftingrecipes.data = data;
            craftingrecipes.Load(MyStream.ReadAllLines(getfile.GetFile("craftingrecipes.csv")));
            server.d_CraftingRecipes = craftingrecipes;
            server.d_Data = data;
            server.d_CraftingTableTool = new CraftingTableTool() { d_Map = map };
            server.LocalConnectionsOnly = !Public;
            server.d_GetFile = getfile;
            var networkcompression = new CompressionGzip();
            var diskcompression = new CompressionGzip();
            var chunkdb = new ChunkDbCompressed() { d_ChunkDb = new ChunkDbSqlite(), d_Compression = diskcompression };
            server.d_ChunkDb = chunkdb;
            map.d_ChunkDb = chunkdb;
            server.d_NetworkCompression = networkcompression;
            map.d_Data = server.d_Data;
            server.d_DataItems = new GameDataItemsBlocks() { d_Data = data };
            server.d_Water = new WaterFinite() { data = server.d_Data };
            server.d_GroundPhysics = new GroundPhysics() { data = server.d_Data };
            server.SaveFilenameWithoutExtension = SaveFilenameWithoutExtension;
            if (Socket == null)
            {
                server.d_MainSocket = new SocketNet()
                {
                    d_Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
                };
            }
            else
            {
                server.d_MainSocket = Socket;
            }
            server.d_Heartbeat = new ServerHeartbeat();
            server.Start();
            if ((Public) && (server.config.Public))
            {
                new Thread((a) => { for (; ; ) { server.SendHeartbeat(); Thread.Sleep(TimeSpan.FromMinutes(1)); } }).Start();
            }
            for (; ; )
            {
                server.Process();
                Thread.Sleep(1);
                if (d_Exit != null && d_Exit.exit) { return; }
            }
        }
开发者ID:henon,项目名称:manic_digger,代码行数:70,代码来源:ServerProgram.cs

示例3: ChildServer

        void ChildServer()
        {
            try
            {
                //Try to create the lockfile at startup
                File.Create(lockFileName);
            }
            catch
            {
                Console.WriteLine("[SERVER] Lockfile could not be created! Shutdown will not work!");
            }
            server = new Server();
            server.exit = new GameExit();
            server.Public = true;
            for (; ; )
            {
                server.Process();
                Thread.Sleep(1);

                //Check if server wants to exit
                if (server.exit != null && server.exit.GetExit())
                {
                    //If so, save data
                    server.Stop();

                    //Check if server wants to be restarted
                    if (!server.exit.GetRestart())
                    {
                        //Delete the lockfile if server wants to be shutdown
                        try
                        {
                            File.Delete(lockFileName);
                        }
                        catch
                        {
                            Console.WriteLine("[SERVER] Lockfile could not be deleted! Server will be restarted!");
                        }
                    }

                    //Finally kill the server process
                    return;
                }

                //Check if parent process is still running
                if (!ENABLE_AUTORESTARTER)
                {
                    //Only do so when automatic restarts are enabled
                    continue;
                }
                if (parentCheckStopwatch == null)
                {
                    parentCheckStopwatch = new Stopwatch();
                    parentCheckStopwatch.Start();
                }
                if (parentCheckStopwatch.Elapsed.Milliseconds > 100)
                {
                    try
                    {
                        Process.GetProcessById(parentid);
                    }
                    catch
                    {
                        //Shutdown the server if parent process could not be found
                        server.Exit();
                        return;
                    }
                    parentCheckStopwatch.Reset();
                    parentCheckStopwatch.Start();
                }
            }
        }
开发者ID:Matthewism,项目名称:manicdigger,代码行数:71,代码来源:Program.cs


注:本文中的Server.Process方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。