Exemplo n.º 1
0
 public Appliaction(JsonValue config)
 {
     this.port             = config["ListenPort"].AsInt();
     this.servicePort      = config["ServicePort"].AsInt();
     Current               = this;
     this.ConnectionString = string.Format(
         "Data Source={0};Initial Catalog={1};Persist Security Info=True;User ID={2};Password={3}",
         config["DBHost"].AsString(),
         config["DBName"].AsString(),
         config["DBUser"].AsString(),
         config["DBPwd"].AsString()
         );
     //MonitorPool = MonitorPool.Singleton;
     MonitorPool.Singleton.Init(this.GetType().Assembly);
     NetProtoTool.EnableLog = config["Log"].AsBoolean();
 }
Exemplo n.º 2
0
        public static void Main(string[] args)
        {
            NetProtoTool.EnableLog = true;
            Debuger.Loger          = new DefaultLoger();
            string json;

            if (args.Length > 0)
            {
                var file = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, args[0]);
                json = File.ReadAllText(file, new UTF8Encoding(false));
                Debuger.Log(json);
            }
            else
            {
                json = "{" +
                       "\"ListenPort\":1900," +
                       "\"ServicePort\":1800," +
                       "\"DBHost\":\"127.0.0.1\"," +
                       "\"DBName\":\"game_account_db\"," +
                       "\"DBUser\":\"root\"," +
                       "\"DBPwd\":\"54249636\"," +
                       "\"Log\":true" +
                       "}";
            }
            var config = JsonReader.Read(json);

            app = new Appliaction(config);
            app.Start();
            var thread = new Thread(Runer);

            thread.IsBackground = false;
            thread.Start();
            var u = new UnixExitSignal();

            u.Exit += (s, e) => {
                Debuger.Log("App will exit");
                app.Stop();// = false;
            };
            while (app.IsRunning)
            {
                Thread.Sleep(100);
#if MONO
#endif
            }

            //thread.Join();
        }