Esempio n. 1
0
        public void Run()
        {
            _Log.Info("AccountServer is starting");

            _Log.Info("Reading configuration");
            _ConfigTree.FromConfigFile("Config/AccountServer.cfg");

            _Log.Info("Connecting to database");
            _DatabaseConnection = new MySqlConnection(BuildConnectionString());

            try
            {
                _DatabaseConnection.Open();
            }
            catch (Exception ex)
            {
                _Log.Fatal("Error connecting to database!", ex);
                return;
            }

            _RemotingServer = new RemotingServer(_ConfigTree.Get("inter.uri", "net.tcp://localhost:5401/"));
            _RemotingServer.ExposeType<CharServerService>("CharServer", typeof(ICharServerService));
            _RemotingServer.Start();
            _Log.InfoFormat("Accepting CharServer connections at {0}", _RemotingServer.BaseUri);

            IPAddress bindAddress = IPAddress.Parse(_ConfigTree.Get("network.interface.ip", "0.0.0.0"));
            int bindPort = _ConfigTree.Get("network.interface.port", 5500);
            _Log.InfoFormat("Accepting connections at {0}:{1}", bindAddress, bindPort);
            _Listener.Bind(bindAddress, bindPort);
            _Listener.Listen();

            _Running = true;
            while (_Running)
                Thread.Yield();

            _RemotingServer.Stop();
        }