nuget安装fleck
using Fleck;
private void StartWS()
{
//创建webscoket服务端实例
var server = new WebSocketServer("ws://127.0.0.1:5333");
server.Start(socket => {
socket.OnOpen = () =>
{
Console.WriteLine("Open");
};
socket.OnClose = () =>
{
Console.WriteLine("Close");
};
socket.OnMessage = message => {
//Console.WriteLine(message);
//textBox1.Text = message;
if (message == "list")
{
socket.Send("发的消息");
while (true)
{
///
Thread.Sleep(500);
}
}
};
});
}
C#开启WebSocket服务端
最新推荐文章于 2024-07-03 23:21:14 发布