Files
wb_InteractiveClassroomMett…/Form1.cs

59 lines
1.6 KiB
C#
Raw Normal View History

2025-12-11 10:06:20 +08:00
using System.Security.Cryptography.X509Certificates;
using Fleck;
namespace SupperWebSocket
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private WebSocketServer _webSocketServer;
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
if (button1.Text == "<22><><EFBFBD><EFBFBD>Socket<65><74><EFBFBD><EFBFBD>")
{
string location = "wss://0.0.0.0:8181";
_webSocketServer = new WebSocketServer();
_webSocketServer.Start(location);
button1.Text = "<22>ر<EFBFBD>WebSocket";
timer1.Interval = 2000;
timer1.Start();
}
else
{
button1.Text = "<22><><EFBFBD><EFBFBD>Socket<65><74><EFBFBD><EFBFBD>";
_webSocketServer.Stop();
timer1.Stop();
}
}
private async void timer1_Tick(object sender, EventArgs e)
{
await Task.Run(() =>
{
this.Invoke(new Action(() =>
{
label5.Text = WebSocketServer._classInfos.Count.ToString();
label6.Text =WebSocketServer.IWebSocketUserinfo.Count.ToString();
label7.Text = WebSocketServer.IWebSocketUserinfo.Where(c=>c.UserType == 1 ).ToList().Count().ToString();
label8.Text = WebSocketServer.IWebSocketUserinfo.Where(c => c.UserType == 0).ToList().Count().ToString();
}));
});
}
}
}