Inheritance: IServer
Esempio n. 1
0
        public SmtpService()
        {
            InitializeComponent();

            _behaviour = new DefaultServerBehaviour();
            _server = new Server(_behaviour);
        }
Esempio n. 2
0
        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;
                }
            }
        }
Esempio n. 3
0
        private void ApplySettings()
        {
            if (_server != null)
            {
                if (_server.IsRunning)
                {
                    Stop();
                }

                if (_server != null)
                {
                    _server.IsRunningChanged -= OnServerStateChanged;
                }

                _server = null;
            }

            TryStart();
        }
Esempio n. 4
0
        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();
        }
Esempio n. 5
0
        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);
                                            }));
            }
        }