本文整理汇总了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;
}
示例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;
}