コード例 #1
0
ファイル: Server.cs プロジェクト: hmailserver/hmailserver-net
 public Server(Func<ISession> sessionFactory, ILog log, ServerConfiguration serverConfiguration)
 {
     _sessionFactory = sessionFactory;
     _configuration = serverConfiguration;
     _listener = new TcpListener(serverConfiguration.IpAddress, serverConfiguration.Port);
     _log = log;
 }
コード例 #2
0
        static void Main(string[] args)
        {
            var client = new DnsClient();

            var log = new Log();

            var config = ServiceConfigurationReader.Read();
            
            var container = new Container(new DependencyRegistry(config));

            var smtpServerSessionConfiguration = new SmtpServerSessionConfiguration
                {
                    TempDirectory = config.TempDirectory
                };

            Func<ISession> smtpSessionFactory = () => 
                new SmtpServerSession(new SmtpServerCommandHandler(container), log, smtpServerSessionConfiguration);

            var serverConfiguration = new ServerConfiguration()
                {
                    Port = 25
                };

            var smtpServer = new Server(smtpSessionFactory, log, serverConfiguration);
            var smtpRunTask = smtpServer.RunAsync();

            Func<ISession> pop3SessionFactory = () =>
             new Pop3ServerSession(new Pop3ServerCommandHandler(container), log, new Pop3ServerSessionConfiguration());

            var pop3ServerConfiguration = new ServerConfiguration()
                {
                    Port = 110
                };



            var deliverer = new MessageDeliverer(container);
            var delivererTask = deliverer.RunAsync();





            var pop3Server = new Server(pop3SessionFactory, log, pop3ServerConfiguration);
            var pop3RunTask = pop3Server.RunAsync();

            log.LogApplicationInfo("Server running...");


            Console.WriteLine("Press any key to exit");
            Console.ReadLine();

            log.LogApplicationInfo("Shutting down");

            var smtpStopTask = smtpServer.StopAsync();
            var pop3StopTask = pop3Server.StopAsync();

        }