/// <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); } }
/// <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); } }
/// <summary> /// The main entry point for the application. /// </summary> /// <param name="args">The arguments. </param> internal static void Main(string[] args) { // todo: create with HostBuilder var loggerFactory = new NullLoggerFactory().AddLog4Net(Log4NetConfigFilePath, true); logger = loggerFactory.CreateLogger <Program>(); var addressResolver = IpAddressResolverFactory.DetermineIpResolver(args, loggerFactory); var settings = new Settings("ChatServer.cfg"); var serviceContainer = new ServiceContainer(); serviceContainer.AddService(typeof(ILoggerFactory), loggerFactory); int chatServerListenerPort = settings.ChatServerListenerPort ?? 55980; int exDbPort = settings.ExDbPort ?? 55906; string exDbHost = settings.ExDbHost ?? "127.0.0.1"; try { // To make the chat server use our configured encryption key, we need to trick a bit. We add an endpoint with a special client version which is defined in the plugin. var configuration = new ChatServerSettings(); configuration.Endpoints.Add(new ChatServerEndpoint { ClientVersion = ConfigurableNetworkEncryptionPlugIn.Version, NetworkPort = chatServerListenerPort }); var pluginManager = new PlugInManager(null, loggerFactory, serviceContainer); pluginManager.DiscoverAndRegisterPlugInsOf <INetworkEncryptionFactoryPlugIn>(); var chatServer = new ChatServer(configuration, addressResolver, loggerFactory, pluginManager); chatServer.Start(); var exDbClient = new ExDbClient(exDbHost, exDbPort, chatServer, chatServerListenerPort, loggerFactory); logger.LogInformation("ChatServer started and ready"); while (Console.ReadLine() != "exit") { // keep application running } exDbClient.Disconnect(); chatServer.Shutdown(); } catch (Exception ex) { logger.LogCritical(ex, "Unexpected error occured"); } }
/// <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 = IpAddressResolverFactory.DetermineIpResolver(args); var settings = new Settings("ChatServer.cfg"); int chatServerListenerPort = settings.ChatServerListenerPort ?? 55980; int exDbPort = settings.ExDbPort ?? 55906; string exDbHost = settings.ExDbHost ?? "127.0.0.1"; try { // To make the chat server use our configured encryption key, we need to trick a bit. We add an endpoint with a special client version which is defined in the plugin. var configuration = new ChatServerSettings(); configuration.Endpoints.Add(new ChatServerEndpoint { ClientVersion = ConfigurableNetworkEncryptionPlugIn.Version, NetworkPort = chatServerListenerPort }); var chatServer = new ChatServer(configuration, null, addressResolver); 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); } }