Jc.WebSocket
1.3.21
dotnet add package Jc.WebSocket --version 1.3.21
NuGet\Install-Package Jc.WebSocket -Version 1.3.21
<PackageReference Include="Jc.WebSocket" Version="1.3.21" />
paket add Jc.WebSocket --version 1.3.21
#r "nuget: Jc.WebSocket, 1.3.21"
// Install Jc.WebSocket as a Cake Addin #addin nuget:?package=Jc.WebSocket&version=1.3.21 // Install Jc.WebSocket as a Cake Tool #tool nuget:?package=Jc.WebSocket&version=1.3.21
Jc.WebSocket
websocket中间件
JcWebSocketServer
.net core webapi Websocket服务中间件
启动方法
//启动方法
app.UseJcWebSocketServer(callBack,isrepeat);
//回调函数处理
void callBack(WebSocketState state,string token, string msg)
{
Console.WriteLine($"state:{state.ToString()}>token:{token}>msg:{msg}");
}
客户端 连接方式:
ws://ip:port?token=your token uuid
token: 当:isrepeat=false 只能是唯一,如果有重复 将关闭上一个链接
为指定Token发送消息
JcWebSocketServer.SendText(token,text)
await JcWebSocketServer.SendTxtAsync(token, text);
为所有连接发送消息
JcWebSocketServer.SendText(text)
获取在线列表
JcWebSocketServer.GetUserList()
关闭指定Token链接
JcWebSocketServer.DisConnect(token)
JcWebSocketClient
.net core webapi Websocket客户端中间件
连接Server
//创建链接
void testWebClient()
{
JcWebSocketClient wSocketClient = new JcWebSocketClient("ws://192.168.1.140:5010?token=2");
wSocketClient.OnOpen -= WSocketClient_OnOpen;
wSocketClient.OnMessage -= WSocketClient_OnMessage;
wSocketClient.OnClose -= WSocketClient_OnClose;
wSocketClient.OnError -= WSocketClient_OnError;
wSocketClient.OnOpen += WSocketClient_OnOpen;
wSocketClient.OnMessage += WSocketClient_OnMessage;
wSocketClient.OnClose += WSocketClient_OnClose;
wSocketClient.OnError += WSocketClient_OnError;
wSocketClient.Open();
wSocketClient.Send("info");
}
void WSocketClient_OnError(object sender, Exception ex)
{
}
void WSocketClient_OnClose(object sender, EventArgs e)
{
}
void WSocketClient_OnMessage(object sender, string data)
{
Console.WriteLine(data);
}
void WSocketClient_OnOpen(object sender, EventArgs e)
{
}
WebSocket在线测试工具
Upgrade content:
v1.0.4
1.Fixed Net6 Mini api compatibility
v1.3.16
1.修复SendTxt 返回状态
v1.3.18
https://zhuanlan.zhihu.com/p/338772340
修复 问题
One or more errors occurred. (The remote party closed the WebSocket connection without completing the close handshake.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.AspNetCore.WebSockets (>= 2.2.1)
-
.NETStandard 2.1
- Microsoft.AspNetCore.WebSockets (>= 2.2.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.3.21 | 104 | 11/14/2024 |
1.3.20 | 89 | 11/14/2024 |
1.3.19 | 302 | 3/15/2023 |
1.3.18 | 273 | 3/7/2023 |
1.3.17 | 363 | 11/16/2022 |
1.3.16 | 350 | 11/15/2022 |
1.2.16 | 383 | 11/12/2022 |
1.2.15 | 358 | 11/12/2022 |
1.2.14 | 368 | 11/12/2022 |
1.2.13 | 360 | 11/11/2022 |
1.2.12 | 366 | 11/9/2022 |
1.2.11 | 361 | 11/9/2022 |
1.0.11 | 495 | 9/14/2022 |
1.0.10 | 505 | 9/14/2022 |
1.0.9 | 448 | 6/14/2022 |
1.0.8 | 451 | 6/14/2022 |
1.0.7 | 450 | 5/13/2022 |
1.0.6 | 457 | 4/27/2022 |
1.0.5 | 459 | 3/19/2022 |
1.0.4 | 465 | 3/19/2022 |
1.0.3 | 481 | 3/8/2022 |
1.0.2 | 477 | 3/8/2022 |
1.0.1 | 469 | 3/8/2022 |