Пример #1
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        /// <param name="args">The arguments. </param>
        internal static void Main(string[] args)
        {
            BasicConfigurator.Configure();
            XmlConfigurator.ConfigureAndWatch(new FileInfo(Log4NetConfigFilePath));
            var settings = new Settings("ChatServer.cfg");

            int    chatServerListenerPort = settings.ChatServerListenerPort ?? 55980;
            int    exDbPort = settings.ExDbPort ?? 55906;
            string exDbHost = settings.ExDbHost ?? "127.0.0.1";

            byte[] customXor32Key = settings.Xor32Key;

            try
            {
                var chatServer = new ChatServerListener(chatServerListenerPort, null);
                chatServer.Xor32Key = customXor32Key ?? chatServer.Xor32Key;
                chatServer.Start();
                var exDbClient = new ExDbClient(exDbHost, exDbPort, chatServer, chatServerListenerPort);
                Log.Info("ChatServer started and ready");
                while (Console.ReadLine() != "exit")
                {
                    // keep application running
                }

                exDbClient.Disconnect();
                chatServer.Shutdown();
            }
            catch (Exception ex)
            {
                Log.Fatal("Unexpected error occured", ex);
            }
        }
Пример #2
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        /// <param name="args">The arguments. </param>
        internal static void Main(string[] args)
        {
            var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());

            XmlConfigurator.ConfigureAndWatch(logRepository, new FileInfo(Log4NetConfigFilePath));
            var addressResolver = args.Contains("-local") ? (IIpAddressResolver) new LocalIpResolver() : new PublicIpResolver();
            var settings        = new Settings("ChatServer.cfg");

            int    chatServerListenerPort = settings.ChatServerListenerPort ?? 55980;
            int    exDbPort = settings.ExDbPort ?? 55906;
            string exDbHost = settings.ExDbHost ?? "127.0.0.1";

            byte[] customXor32Key = settings.Xor32Key;

            try
            {
                var chatServer = new ChatServerListener(chatServerListenerPort, null, addressResolver);
                chatServer.Xor32Key = customXor32Key ?? chatServer.Xor32Key;
                chatServer.Start();
                var exDbClient = new ExDbClient(exDbHost, exDbPort, chatServer, chatServerListenerPort);
                Log.Info("ChatServer started and ready");
                while (Console.ReadLine() != "exit")
                {
                    // keep application running
                }

                exDbClient.Disconnect();
                chatServer.Shutdown();
            }
            catch (Exception ex)
            {
                Log.Fatal("Unexpected error occured", ex);
            }
        }