Beispiel #1
0
        private static void Main(string[] args)
        {
            CommunicationServer communicationServer;

            try
            {
                var config = ServerConfigurationSection.LoadConfig("serverConfig", args);

                var serverAddress = IpEndPointParser.Parse(config.Address, config.Port);
                var timeout       = config.Timeout;
                var isBackup      = config.IsBackup;

                IPEndPoint masterServerAddress;
                if (isBackup)
                {
                    masterServerAddress = IpEndPointParser.Parse(config.MasterServer.Address, config.MasterServer.Port);
                }

                //_logger.Info("Server address: " + serverAddress);

                var serverConfig = new ServerConfig
                {
                    Mode    = isBackup ? ServerConfig.ServerMode.Backup : ServerConfig.ServerMode.Primary,
                    Address = serverAddress,
                    CommunicationTimeout = timeout
                };

                communicationServer = new CommunicationServer(serverConfig);
            }
            catch (Exception ex)
            {
                var errorText = string.Format("{0}:{1}", ex.GetType().FullName, ex.Message);
                if (ex.InnerException != null)
                {
                    errorText += string.Format("|({0}:{1})", ex.InnerException.GetType().FullName,
                                               ex.InnerException.Message);
                }
                //_logger.Error(errorText);
                return;
            }

            communicationServer.Start();

            while (Console.ReadLine() != "exit")
            {
                // input handling
            }

            communicationServer.Stop();
        }
Beispiel #2
0
        private static void Main(string[] args)
        {
            CommunicationServer communicationServer;
            try
            {
                var config = ServerConfigurationSection.LoadConfig("serverConfig", args);

                var serverAddress = IpEndPointParser.Parse(config.Address, config.Port);
                var timeout = config.Timeout;
                var isBackup = config.IsBackup;

                IPEndPoint masterServerAddress;
                if (isBackup)
                    masterServerAddress = IpEndPointParser.Parse(config.MasterServer.Address, config.MasterServer.Port);

                //_logger.Info("Server address: " + serverAddress);

                var serverConfig = new ServerConfig
                {
                    Mode = isBackup ? ServerConfig.ServerMode.Backup : ServerConfig.ServerMode.Primary,
                    Address = serverAddress,
                    CommunicationTimeout = timeout
                };

                communicationServer = new CommunicationServer(serverConfig);
            }
            catch (Exception ex)
            {
                var errorText = string.Format("{0}:{1}", ex.GetType().FullName, ex.Message);
                if (ex.InnerException != null)
                    errorText += string.Format("|({0}:{1})", ex.InnerException.GetType().FullName,
                        ex.InnerException.Message);
                //_logger.Error(errorText);
                return;
            }

            communicationServer.Start();

            while (Console.ReadLine() != "exit")
            {
                // input handling
            }

            communicationServer.Stop();
        }