/// <summary> /// Stops the TCP Server /// </summary> protected void TCPServerStop() { if (_messageServer != null) { _messageServer.Stop(); } }
public void Go(ServerContext sCtx, ClientContext cCtx) { _sCtx = sCtx; _cCtx = cCtx; var mr = false; var server = new MessageServer(sCtx); sCtx.M.RegisterAsync <HelloRequest>(this, x => { sCtx.M.Send(new HelloResponse(x)); }); cCtx.Messenger.RegisterAsync <HelloResponse>(this, x => { cCtx.Logger.Log(x.Response + " " + x.ClientId); mr = true; }); server.Start(); SendAsClient(server, cCtx.Messenger, new HelloRequest()); do { Thread.Sleep(1); } while (!mr); server.Stop(); }
/// <summary> /// Stops the message server. /// </summary> private void Stop() { lock (_objLock) { if (_messageServer != null) { _messageServer.Stop(); } _messageServer = null; Log.Info("Stopped GodLesZ.Library.Amf Gateway"); } }
/// <summary> /// Stops the message server. /// </summary> private void Stop() { lock (_objLock) { if (_messageServer != null) { _messageServer.Stop(); } _messageServer = null; Log.Info("Stopped FluorineFx Gateway"); } }
static void Main(string[] args) { Trace.Listeners.Add(new ConsoleTraceListener()); // 启动服务器 using (MessageServer server = new MessageServer()) { server.Port = 8088; server.Start(); Console.WriteLine("Press enter key to exit..."); Console.ReadLine(); server.Stop(); } }
/// <summary> /// [implementation of IHostedService] /// Triggered when the host is performing a graceful shutdown. /// StopAsync contains the logic to end the background task. /// Implement IDisposable and finalizers (destructors) to dispose of any unmanaged resources. /// </summary> /// <param name="cancellationToken">Indicates that the shutdown process should no longer be graceful.</param> /// <returns>Task</returns> public Task StopAsync(CancellationToken cancellationToken) { if (_server != null && _server.IsStarted) { _server.Stop(); _logger.LogInformation("TcpServer STOPPED"); _fileLogger.WriteProgramLog($"{DateTime.Now:yyyy-MM-dd HH:mm:ss} TcpServer STOPPED"); } else { _logger.LogWarning("TcpServer already stopped"); _fileLogger.WriteProgramLog($"{DateTime.Now:yyyy-MM-dd HH:mm:ss} TcpServer already stopped"); } return(Task.CompletedTask); }
void CurrentDomain_DomainUnload(object sender, EventArgs e) { try { lock (_objLock) { if (messageServer != null) { messageServer.Stop(); } messageServer = null; } } catch (Exception) { } }
public static void Main() { try { MessageServer.LoginServerConnection = new InteroperabilityClient(new IPEndPoint( Settings.GetIPAddress("IP", "Interconnection"), Settings.GetInt("Port", "Interconnection")), Settings.GetString("SecurityCode", "Interconnection")); MessageServer.LoginServerConnection.Loop(); } catch (Exception e) { Log.Error("Server connection failed: \n{0}", e.ToString()); MessageServer.Stop(); } }
private void CurrentDomain_DomainUnload(object sender, EventArgs e) { try { lock (_objLock) { if (messageServer != null) { messageServer.Stop(); } messageServer = null; } LogManager.GetLogger(typeof(FluorineGateway)).Info("Stopped FluorineFx Gateway"); } catch (Exception) { } }
protected override void StopServer() { MessageServer.Stop(); }
public void Stop() { net_server.Stop(); net_server.Join(); }