/// <summary>停止工作</summary> protected override void StopWork(String reason) { Svr.TryDispose(); Svr = null; base.StopWork(reason); }
/// <summary>启动工作</summary> protected override void StartWork(String reason) { base.StartWork(reason); // 每次上线清空一次在线表 _timer = new TimerX(CheckExpire, null, 0, 60000); var set = Setting.Current; // 实例化服务器 Svr = new LinkServer { Name = "平台", Port = set.Port, }; Svr.Log = XTrace.Log; Svr.SetLog(set.Debug, set.SocketDebug, set.EncoderDebug); // 遍历注册各服务控制器 Svr.Register <DeviceController>(); Svr.Register <UserController>(); Svr.Start(); if (set.EncoderDebug) { Svr.Encoder.Log = Svr.Log; } // 如果是控制台调试,则在标题显示统计 if (!Environment.CommandLine.EndsWith(" -s")) { _Timer = new TimerX(ShowStat, null, 1000, 1000) { Async = true } } ; }
/// <summary>启动工作</summary> protected override void StartWork(String reason) { base.StartWork(reason); var set = Setting.Current; // 实例化服务器 var svr = new LinkServer { Name = "平台", Port = set.Port, }; svr.Log = XTrace.Log; svr.SetLog(set.Debug, set.SocketDebug, set.EncoderDebug); // 遍历注册各服务控制器 svr.Add <DeviceService>(); svr.Add <UserService>(); svr.Start(); Svr = svr; }