public MainWindow() { InitializeComponent(); this.DataContext = dataContext; Task.Factory.StartNew(UpdateP2PMessage); LogUtils.ClientRecordLogHandler = Instance_RecordLogEvent; clientModule.Start(); }
public void Start() { if (_started) { throw new Exception("Core is already started"); } // TODO: Move this to the master node, where we can either query the live status of the // current node or query the last-known status of the requested node. // Also, be clear whether we are querying by NodeId or NetworkNodeId (the former is // more likely) //_subscriptions.Listen<NodeStatusRequest, NodeStatus>(l => l.OnDefaultChannel().Invoke(r => GetStatus(r.NodeId))); Modules.AddMissingModules(this); CoreModule.Start(); Modules.StartAll(); Modules.WarnOnMissingModules(Log); _started = true; MessageBus.Publish(CoreEvent.ChannelInitialized, new CoreEvent()); // TODO: Report version? Other details? Log.LogInformation("Core initialized Id={0}", NodeId); }
private void Form1_Load(object sender, EventArgs e) { LogTextBox.AppendText("\r\n"); LogTextBox.AppendText("************************************************************************\r\n"); LogTextBox.AppendText("* P2P内网穿透桌面客户端 作者:ZeroDeng *\r\n"); LogTextBox.AppendText("* 需要更专业的配置请自行手动修改配置文件 *\r\n"); LogTextBox.AppendText("* 感谢内核作者:wireboy *\r\n"); LogTextBox.AppendText("* 有好的建议或者意见请移步github提交issues *\r\n"); LogTextBox.AppendText("* 客户端github地址:https://github.com/ZeroDeng01/P2PSocket.Client.WFM *\r\n"); LogTextBox.AppendText("************************************************************************\r\n"); LogTextBox.AppendText("\r\n"); if (Config.IsExistConfig()) { //加载服务端地址 ServerAddressTextBox.Text = ini.IniReadValue("Common", "ServerAddress"); //加载客户端名称 string clientName = ini.IniReadValue("Common", "ClientName"); if (clientName.Trim().Length > 0) { ClientNameTextBox.Text = clientName; } else { clientName = BitConverter.ToUInt32(Guid.NewGuid().ToByteArray(), 8).ToString(); ClientNameTextBox.Text = clientName; ini.IniWriteValue("Common", "ClientName", clientName); } //加载被控端口 string allowPortStr = ini.IniReadValue("Common", "AllowPort"); if (!"".Equals(allowPortStr)) { if (allowPortStr.IndexOf(',') != -1) { allowPorts = new BindingList <string>(allowPortStr.Split(',').ToList()); } else { allowPorts.Add(allowPortStr); } } AllowPortListBox.DataSource = allowPorts; //初始化日志回调 EasyInject.Get <ILogger>().OnWriteLog += PipeServer_OnWriteLog; //初始启动P2PSocket clientModule.Start(); AppConfig config = new AppConfig(); List <string> portmap = ini.GetPortMapItems(); if (portmap != null) { foreach (string s in portmap) { portMapItems.Add(s); } PortMapItemListBox.DataSource = portMapItems; } } else { Log("配置文件缺失,正在创建"); if (!Directory.Exists(Config.RuntimePath)) //不存在文件夹,创建 { Directory.CreateDirectory(Config.RuntimePath); //创建新的文件夹 } FileStream fs = File.Create(Config.ConfigFile); //创建文件 fs.Close(); Log("配置文件创建完毕"); Form1_Load(sender, e); } }
public void TestServerStart() { CoreModule coreModule = new CoreModule(); coreModule.Start(); }