You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
|
using Autofac;
|
|
|
|
|
using Autofac.Core;
|
|
|
|
|
using DotNetty.Handlers.Logging;
|
|
|
|
|
using HybirdFrameworkCore.Autofac;
|
|
|
|
|
using log4net;
|
|
|
|
|
using Service.TBox.Server;
|
|
|
|
|
|
|
|
|
|
namespace WinFormStarter;
|
|
|
|
|
|
|
|
|
|
public partial class Form2 : Form
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
private static readonly ILog Log = LogManager.GetLogger(typeof(Form2));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private TBoxServer? server = null;
|
|
|
|
|
public Form2()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
this.txtPort.Text = "9999";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void AppendText(RichTextBox r, string msg)
|
|
|
|
|
{
|
|
|
|
|
if (r.InvokeRequired)
|
|
|
|
|
{
|
|
|
|
|
r.Invoke(() =>
|
|
|
|
|
{
|
|
|
|
|
r.AppendText(msg);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
r.AppendText(msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnConn_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string portTxt = txtPort.Text;
|
|
|
|
|
if (!int.TryParse(portTxt, out var port))
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("请输入端口号");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (server == null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
foreach (var reg in AppInfo.Container.ComponentRegistry.Registrations)
|
|
|
|
|
foreach (var service in reg.Services)
|
|
|
|
|
if (service is TypedService ts)
|
|
|
|
|
Log.Info(ts.ServiceType);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
server = AppInfo.Container.Resolve<TBoxServer>();
|
|
|
|
|
server.LogLevel = LogLevel.TRACE;
|
|
|
|
|
server.Start(port);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MessageBox.Show($"启动成功, 监听{port}");
|
|
|
|
|
}
|
|
|
|
|
}
|