56 lines
1.6 KiB
C#
56 lines
1.6 KiB
C#
|
|
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:8182";
|
|||
|
|
_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();
|
|||
|
|
}));
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|