本文整理汇总了C#中ServerState类的典型用法代码示例。如果您正苦于以下问题:C# ServerState类的具体用法?C# ServerState怎么用?C# ServerState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServerState类属于命名空间,在下文中一共展示了ServerState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleMenuStartServer
private void HandleMenuStartServer(object sender, RoutedEventArgs e)
{
serverState = ServerState.RUNNING;
serverMiniCheckers.UpdateMenuState(serverState);
updateRequestResponse("Server started");
Debug.WriteLine("Server Starting");
}
示例2: GetServerState
public HttpResponseMessage GetServerState(ServerState serverState)
{
var httpResponseMessage = new HttpResponseMessage();
httpResponseMessage.StatusCode = HttpStatusCode.OK;
httpResponseMessage.Content = new StringContent((string)serverState["Hello"], System.Text.Encoding.UTF8, "text/plain");
return httpResponseMessage;
}
示例3: Main
static void Main(string[] args)
{
var serviceLocator = new ServiceLocator(CreateDIContainer());
var baseurl = new Uri("http://localhost:1000/");
var serverState = new ServerState();
serverState["Hello"] = "World";
var config = new HttpConfiguration();
config.CreateInstance = (type, context, request) => serviceLocator.GetInstance(type);
config.RequestHandlers = (handlers, se, od) => handlers.Add(new ServerStateOperationHandler(serverState));
config.ResponseHandlers = (handlers, se, od) => {
handlers.Add(new LoggingOperationHandler(new Logger()));
handlers.Add(new CompressionHandler());
};
config.Formatters.Insert(0, new JsonMediaTypeFormatter());
HttpServiceHost host = new HttpServiceHost(typeof(FooService), config, baseurl);
host.Open();
Console.WriteLine("Host open. Hit enter to exit...");
Console.WriteLine("Use a web browser and go to " + baseurl + " or do it right and get fiddler!");
Console.Read();
host.Close();
}
示例4: Initialize
public void Initialize()
{
_state = ServerState.LOADING;
CreateRemotingObjects();
_residentOpenSAGEReadyMutex = new Mutex(true, OpenSAGERemoteSettings.ResidentOpenSAGEReadyMutexName);
_state = ServerState.READY;
}
示例5: RaisePacketHandled
private void RaisePacketHandled(int id, IPacket packet, ServerState? state)
{
if (DebugPackets)
PacketsReceived.Add(packet);
if (OnPacketHandled != null)
OnPacketHandled(id, packet, state);
}
示例6: WebSocketServiceHostManager
internal WebSocketServiceHostManager(Logger logger)
{
_logger = logger;
_keepClean = true;
_serviceHosts = new Dictionary<string, WebSocketServiceHost> ();
_state = ServerState.READY;
_sync = new object ();
}
示例7: ListenForConnections
public void ListenForConnections()
{
state = ServerState.RUNNING;
connectionListenerThread = new Thread(new ThreadStart(ConnectionListenerHandler));
connectionListenerThread.Start();
//eventCheckerThread = new Thread(new ThreadStart(CheckForEvents));
//eventCheckerThread.Start();
}
示例8: HandleMenuStopServer
private void HandleMenuStopServer(object sender, RoutedEventArgs e)
{
serverState = ServerState.STOPPED;
serverMiniCheckers.UpdateMenuState(serverState);
updateRequestResponse("Server stopped");
Debug.WriteLine("Server Stopping");
}
示例9: ServerOld
public ServerOld(int id, string dataDir)
{
_id = id;
_dataDir = dataDir;
_peers = new List<Peer>();
_random = new Random(id ^ (int)DateTime.Now.Ticks);
_state = ServerState.Stopped;
}
示例10: stepDown
protected void stepDown(IConsensus model, int term)
{
if (_state == ServerState.Leader || _state == ServerState.Candidate)
_state = ServerState.Follower;
_persistedState.UpdateState(term, null);
if (isElectionTimeout(model))
updateElectionAlarm(model);
}
示例11: HandleServerStatusChange
private void HandleServerStatusChange(ServerState currentState)
{
//suport for calls from other threads
if (InvokeRequired)
{
Invoke((MethodInvoker) (() => HandleServerStatusChange(currentState)));
}
else
{
switch (currentState)
{
case ServerState.Starting:
btnStartStop.Enabled = false;
btnRestart.Enabled = false;
btnStartStop.Text = Locale.Tr("Starting...");
break;
case ServerState.Running:
if (ProcessHandler.Server.IsLocal)
{
btnStartStop.Text = Locale.Tr("Stop");
metroToolTip.SetToolTip(btnStartStop, "Stop the server");
}
else
{
metroToolTip.SetToolTip(btnStartStop, "Disconnect from the server");
btnStartStop.Text = Locale.Tr("Disconnect");
}
btnStartStop.Enabled = true;
btnRestart.Enabled = true;
btnStartStop.Text = Locale.Tr("Stop");
break;
case ServerState.Stopping:
btnStartStop.Enabled = false;
btnRestart.Enabled = false;
btnStartStop.Text = Locale.Tr("Stopping...");
break;
case ServerState.Stopped:
btnStartStop.Enabled = true;
btnRestart.Enabled = false;
if (ProcessHandler.Server.IsLocal)
{
btnStartStop.Text = Locale.Tr("Start");
metroToolTip.SetToolTip(btnStartStop, "Start the server");
}
else
{
btnStartStop.Text = Locale.Tr("Connect");
metroToolTip.SetToolTip(btnStartStop, "Connect to the server");
}
break;
}
}
}
示例12: HandleAsync
protected override void HandleAsync(Packet packet)
{
_state = _state ?? (ServerState) State;
foreach (var endPoint in _state.Users.GetAllExcept(packet.Address))
{
LogManager.Debug("Packet from {0} redirected to {1}", packet.UserName, endPoint);
_state.Client.Send(packet, endPoint);
}
}
示例13: ChangeState
void ChangeState(ServerState newState)
{
Debug.Log("Change State: " + serverState + " >> " + newState);
if (serverState == newState) {
return;
}
ExitState();
serverState = newState;
EnterState();
}
示例14: ServerEnteredErrorStateException
/// <summary>
/// Initializes a new instance of the <see cref="ServerEnteredErrorStateException"/> class
/// with the specified error state.
/// </summary>
/// <param name="status">The error state entered by the server.</param>
/// <exception cref="ArgumentNullException">If <paramref name="status"/> is <see langword="null"/>.</exception>
public ServerEnteredErrorStateException(ServerState status)
: base(string.Format("The server entered an error state: '{0}'", status))
{
if (status == null)
throw new ArgumentNullException("status");
_state.Status = status.Name;
#if !NET35
SerializeObjectState += (ex, args) => args.AddSerializedState(_state);
#endif
}
示例15: UpdateServerState
public void UpdateServerState(FeedbackLevel workload, int peerCount, ServerState state)
{
if (!this.IsRegistered)
{
return;
}
var contract = new UpdateServerEvent { LoadIndex = (byte)workload, PeerCount = peerCount, State = (int)state };
var eventData = new EventData((byte)ServerEventCode.UpdateServer, contract);
this.SendEvent(eventData, new SendParameters());
}