コード例 #1
0
 public void Start()
 {
     try
     {
         LogUtils.Info($"客户端版本:{appCenter.SoftVerSion} 作者:wireboy", false);
         LogUtils.Info($"github地址:https://github.com/bobowire/Wireboy.Socket.P2PSocket", false);
         //读取配置文件
         if (configManager.IsExistConfig())
         {
             //加载配置文件
             appCenter.Config = configManager.LoadFromFile() as AppConfig;;
             FileSystemWatcher fw = new FileSystemWatcher(Path.Combine(appCenter.RuntimePath, "P2PSocket"), "Server.ini")
             {
                 NotifyFilter = NotifyFilters.LastWrite
             };
             fw.Changed            += Fw_Changed;
             fw.EnableRaisingEvents = true;
             //启动服务
             P2PServer.StartServer();
         }
         else
         {
             LogUtils.Error($"找不到配置文件.{appCenter.ConfigFile}");
         }
     }
     catch (Exception ex)
     {
         LogUtils.Error($"启动失败:{ex}");
     }
     System.Threading.Thread.Sleep(1000);
 }
コード例 #2
0
 public void Start()
 {
     try
     {
         LogUtils.InitConfig();
         LogUtils.Info($"程序版本:{Global.SoftVerSion}  通讯协议:{Global.DataVerSion}");
         //读取配置文件
         if (ConfigUtils.IsExistConfig())
         {
             //初始化全局变量
             InitGlobal();
             //加载配置文件
             ConfigUtils.LoadFromFile();
             //启动服务
             P2PServer.StartServer();
             //todo:控制台显示
         }
         else
         {
             LogUtils.Show("启动失败,配置文件不存在.");
         }
     }
     catch (Exception ex)
     {
     }
 }
コード例 #3
0
 public void Start()
 {
     try
     {
         LogUtils.InitConfig();
         LogUtils.Info($"程序版本:{Global.SoftVerSion}  通讯协议:{Global.DataVerSion}");
         //读取配置文件
         if (ConfigUtils.IsExistConfig())
         {
             //初始化全局变量
             InitGlobal();
             //加载配置文件
             ConfigUtils.LoadFromFile();
             //启动服务
             P2PServer.StartServer();
             //todo:控制台显示
         }
         else
         {
             LogUtils.Error($"找不到配置文件.{Global.ConfigFile}");
         }
     }
     catch (Exception ex)
     {
         LogUtils.Error($"启动失败:{ex}");
     }
     System.Threading.Thread.Sleep(1000);
 }
コード例 #4
0
 public void Start(int serverPort, PortMapItem[] portMaps)
 {
     Global.LocalPort = serverPort;
     if (portMaps != null)
     {
         foreach (var portMap in portMaps)
         {
             if (!Global.PortMapList.Any(t => t.LocalPort == portMap.LocalPort))
             {
                 Global.PortMapList.Add(portMap);
             }
         }
     }
     InitGlobal();
     P2PServer.StartServer();
 }
コード例 #5
0
 public void Start()
 {
     ConsoleUtils.WriteLine($"P2PServer - > 程序版本:{Global.SoftVerSion}");
     ConsoleUtils.WriteLine($"P2PServer - > 通讯协议:{Global.DataVerSion}");
     //读取配置文件
     if (ConfigUtils.IsExistConfig())
     {
         //初始化全局变量
         InitGlobal();
         //加载配置文件
         ConfigUtils.LoadFromFile();
         //启动服务
         P2PServer.StartServer();
         //todo:控制台显示
     }
     else
     {
         ConsoleUtils.WriteLine("启动失败,配置文件不存在.");
     }
 }