本文整理匯總了C#中Server.Server.SetStatus方法的典型用法代碼示例。如果您正苦於以下問題:C# Server.SetStatus方法的具體用法?C# Server.SetStatus怎麽用?C# Server.SetStatus使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Server.Server
的用法示例。
在下文中一共展示了Server.SetStatus方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Main
private static void Main(string[] args)
{
var channelServ = new TcpChannel();
ChannelServices.RegisterChannel(channelServ, false);
var mainServer = (IMainServer) Activator.GetObject(typeof (IMainServer), Config.RemoteMainserverUrl);
ServerInit serverInit = mainServer.AddServer();
channelServ.StopListening(null);
ChannelServices.UnregisterChannel(channelServ);
var server = new Server(serverInit);
IDictionary properties = new Hashtable();
int serverPort = Config.GetServerPort(serverInit.Uuid);
const int serverTimeout = Config.InvocationTimeout;
properties["port"] = serverPort;
properties["timeout"] = serverTimeout;
channelServ = new TcpChannel(properties, null, null);
ChannelServices.RegisterChannel(channelServ, false);
RemotingServices.Marshal(server, Config.RemoteServerObjName);
server.StartSplitLock();
foreach (var faultDetection in serverInit.FaultDetection)
{
var fd = (IServer) Activator.GetObject(typeof (IServer), Config.GetServerUrl(faultDetection.Key));
fd.OnFaultDetectionReborn(serverInit.Uuid);
}
int backupId = -1;
if ((serverInit.FaultDetection.Count == 1 && serverInit.FaultDetection.ContainsKey(serverInit.Parent) &&
serverInit.Parent != -1) || (serverInit.FaultDetection.Count == 0 && serverInit.Parent != -1))
{
backupId = serverInit.Parent;
}
else if (serverInit.FaultDetection.Count > 0)
{
backupId = serverInit.FaultDetection.Keys.Max();
}
if (backupId != -1)
{
/* Get data from backup */
var backupServer = (IServer) Activator.GetObject(typeof (IServer), Config.GetServerUrl(backupId));
backupServer.StartSplitLock();
ParticipantStatus status = backupServer.OnChild(serverInit.Uuid, serverInit.Version,
serverInit.ServerCount);
server.SetStatus(status);
backupServer.EndSplitLock();
}
else
{
Console.WriteLine("Server need to have a backup server! Is it the first one?");
}
server.EndSplitLock();
Console.WriteLine("Press <enter> to exit");
Console.ReadLine();
}