using System;
using System.Windows.Forms;
using XiaoFeng.Net;
using XiaoFeng;
namespace WindowsFormsApp2
{
public partial class Form2 : Form
{
public delegate void TestDelegate();
public Form2()
{
InitializeComponent();
}
NetClient<ClientSession> client;
private void Form1_Load(object sender, EventArgs e)
{
client = new NetClient<ClientSession>("127.0.0.1", 8888);
client.OnMessageByte += (o, m, ea) =>
{
this.Invoke(new TestDelegate(() =>
{
this.richTextBox2.AppendText($"server:{m.GetString()}");
}));
};
client.Start();
}
private void button1_Click(object sender, EventArgs e)
{
client.Send(this.richTextBox1.Text);
this.richTextBox1.Clear();
}
private void button2_Click(object sender, EventArgs e)
{
client.SendFile(@"D:\TestCode\xiaofengCode\XiaoFeng\x.png");
}
}
}