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


C# Server.clearState方法代码示例

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


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

示例1: hostServer

        static ServerStatus hostServer(ServerSettings.ConfigStore settings)
        {
            Server server = new Server(settings);

            try
            {
                server.hostingLoop();
            }
            catch (Exception e)
            {
                Log.Error("Unexpected exception encountered! Crash report written to log file");
                Log.Error(e.ToString());
                if (server.threadExceptionStackTrace != null && server.threadExceptionStackTrace.Length > 0)
                {
                    Log.Error("Stacktrace: ");
                    Log.Error(server.threadExceptionStackTrace);
                }
                //server.clearState();
                //return ServerStatus.CRASHED;
            }

            server.clearState();

            if (server.stop)
                return ServerStatus.STOPPED;

            if (!settings.autoRestart || server.quit)
                return ServerStatus.QUIT;

            return ServerStatus.RESTARTING;
        }
开发者ID:NiFree,项目名称:KerbalMultiPlayer,代码行数:31,代码来源:ServerMain.cs

示例2: hostServer

        static ServerStatus hostServer(ServerSettings.ConfigStore settings)
        {
            server = new Server(settings);

            try
            {
                server.hostingLoop();
            }
            catch (SocketException e)
            {
                var se = (SocketError)e.ErrorCode;
                switch (se)
                {
                    case SocketError.AddressAlreadyInUse:
                        Log.Error("Specified port number {0} is already in use by another process.", settings.port);
                        break;
                    case SocketError.AddressNotAvailable:
                        Log.Error("Your specified IP binding ({0}) is not valid. You must use an IP address belonging to a network interface on this system. Use 0.0.0.0 to use all available interfaces.", settings.ipBinding);
                        break;
                    case SocketError.AccessDenied:
                        Log.Error("You do not have permission to open a socket. Make sure the port number you are using is above 1000");
                        break;
                    default:
                        Log.Error("Unable to start server. Error code was {0} ({1}).", e.ErrorCode, se.ToString());
                        Log.Error(e.Message);
                        break;
                }
            }
            catch (Exception e)
            {
                Log.Error("Unexpected exception encountered! Crash report written to log file");
                Log.Error(e.ToString());
                if (server.threadExceptionStackTrace != null && server.threadExceptionStackTrace.Length > 0)
                {
                    Log.Error("Stacktrace: ");
                    Log.Error(server.threadExceptionStackTrace);
                }
                //server.clearState();
                //return ServerStatus.CRASHED;
            }

            server.clearState();

            if (server.stop)
                return ServerStatus.STOPPED;

            if (!settings.autoRestart || server.quit)
                return ServerStatus.QUIT;

            return ServerStatus.RESTARTING;
        }
开发者ID:RockyTV,项目名称:KerbalMultiPlayer,代码行数:51,代码来源:ServerMain.cs


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