public SmtpService() { InitializeComponent(); _behaviour = new DefaultServerBehaviour(); _server = new Server(_behaviour); }
public void TryStart() { ServerError = null; Settings settings = _settingsStore.Load(); if (settings.IsEnabled) { try { _server = new Server(new Smtp4devServerBehaviour(settings, OnMessageReceived)); _server.IsRunningChanged += OnServerStateChanged; _server.Start(); } catch (Exception e) { ServerError = e; } } }
private void ApplySettings() { if (_server != null) { if (_server.IsRunning) { Stop(); } if (_server != null) { _server.IsRunningChanged -= OnServerStateChanged; } _server = null; } TryStart(); }
public Connection(Server server, TcpClient tcpClient) { VerbMap = new VerbMap(); Session = new Session() { ClientAddress = ((IPEndPoint) tcpClient.Client.RemoteEndPoint).Address, StartDate = DateTime.Now }; Server = server; _tcpClient = tcpClient; _tcpClient.ReceiveTimeout = Server.Behaviour.GetReceiveTimeout(this); ReaderEncoding = new ASCIISevenBitTruncatingEncoding(); _stream = tcpClient.GetStream(); SetupReaderAndWriter(); SetupVerbs(); }
private void ServerWork() { try { Application.DoEvents(); ServerBehaviour b = new ServerBehaviour(); b.MessageReceived += OnMessageReceived; b.SessionCompleted += OnSessionCompleted; _server = new Server(b); _server.Run(); } catch (Exception exception) { Invoke((MethodInvoker)(() => { StopServer(); statusLabel.Text = "Server failed: " + exception.Message; trayIcon.ShowBalloonTip(3000, "Server failed", exception.Message, ToolTipIcon.Error); })); } }