Example #1
0
 public LazynetAppServer(LazynetAppContext context)
 {
     // 上下文
     this.Context = context;
     this.Server  = new LazynetServer(new LazynetServerConfig()
     {
         Heartbeat  = this.Context.Config.Heartbeat,
         Port       = this.Context.Config.Port,
         SocketType = this.Context.Config.SocketType
     });
 }
Example #2
0
        public LazynetAppManager Builder()
        {
            try
            {
                // 获取配置文件配置
                var configInfo = new ConfigurationBuilder()
                                 .SetBasePath(Directory.GetCurrentDirectory())
                                 .AddJsonFile("appsettings.json", optional: true)
                                 .Build();
                var luaScriptConfiguration = configInfo.GetSection("Script");

                // 初始化并配置参数
                this.Context        = new LazynetAppContext();
                this.Context.Config = new LazynetAppConfig();

                // logger
                this.Context.Logger = new LazynetLogger("log4net.config");

                // timer
                this.Context.Timer = new LazynetTimerManager();

                // 创建service
                this.Context.ActionProxy = new LazynetActionProxy(this.Context);

                // 创建nodes
                this.Context.Nodes = new LazynetNodeCollection();

                // lua
                this.Context.Lua = new LazynetLua();
                this.Context.Lua.DoFile(luaScriptConfiguration["MainFile"], luaScriptConfiguration["RootDir"]);
            }
            catch (Exception ex)
            {
                this.Context.Logger.Error(ex.ToString());
            }

            return(this);
        }
Example #3
0
 public LazynetServerHandler(LazynetAppContext context)
 {
     this.Context = context;
 }