TouchSocketPro.SocketIo
4.2.9
Prefix Reserved
.NET 6.0
This package targets .NET 6.0. The package is compatible with this framework or higher.
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
.NET Framework 4.6.2
This package targets .NET Framework 4.6.2. The package is compatible with this framework or higher.
dotnet add package TouchSocketPro.SocketIo --version 4.2.9
NuGet\Install-Package TouchSocketPro.SocketIo -Version 4.2.9
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="TouchSocketPro.SocketIo" Version="4.2.9" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TouchSocketPro.SocketIo" Version="4.2.9" />
<PackageReference Include="TouchSocketPro.SocketIo" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TouchSocketPro.SocketIo --version 4.2.9
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: TouchSocketPro.SocketIo, 4.2.9"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package TouchSocketPro.SocketIo@4.2.9
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TouchSocketPro.SocketIo&version=4.2.9
#tool nuget:?package=TouchSocketPro.SocketIo&version=4.2.9
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
TouchSocketPro.SocketIo
TouchSocket 框架的企业版 Socket.IO 组件,在基础版客户端之上提供完整的 Socket.IO 服务端实现。
相比基础版新增
| 能力 | 基础版 (TouchSocket.SocketIo) | 企业版 (TouchSocketPro.SocketIo) |
|---|---|---|
| Socket.IO 客户端 | ? | ?(包含) |
| Socket.IO 服务端 | ? | ? |
| 会话管理 | ? | ? ISocketIoService |
| 心跳超时清理 | ? | ? 自动检测 |
| 依赖注入集成 | ? | ? AddSocketIoService() |
服务端特性
- 双模式传输 — 同时支持 WebSocket 和 HTTP 长轮询
- 自动升级 — 客户端可从 HTTP 轮询无缝升级到 WebSocket
- 会话管理 —
ISocketIoService维护所有已连接会话 - 心跳机制 — 可配置 Ping 间隔和 Pong 超时,自动清理死会话
- 连接验证 — 通过
SetVerifyConnection自定义鉴权逻辑 - 插件扩展 —
ISocketIoEventPlugin处理事件,ISocketIoHandshakedPlugin监听握手
快速使用
配置服务端
// 注册服务
container.AddSocketIoService();
// 配置插件
pluginManager.UseSocketIoServer(options =>
{
options.SetUrl("/socket.io/");
options.PingInterval = 25000;
options.PingTimeout = 20000;
options.AllowUpgrade = true;
});
处理事件
public class MyPlugin : ISocketIoEventPlugin
{
public async Task OnSocketIoReceivedEvent(object client, SocketIoEventArgs e)
{
var name = e.Event;
var arg0 = e.GetValue<string>(0);
await e.AckAsync("ok");
}
}
服务端配置参数
| 参数 | 默认值 | 说明 |
|---|---|---|
PingInterval |
25000ms | 服务端 Ping 间隔 |
PingTimeout |
20000ms | 客户端 Pong 超时 |
MaxPayload |
65536 | 单次消息最大负载 |
SessionTimeout |
60s | 轮询会话超时 |
AllowUpgrade |
true | 是否允许轮询升级到 WebSocket |
支持的目标框架
- net462
- netstandard2.0
- netstandard2.1
- net6.0
- net8.0
- net10.0
文档
详细说明文档:https://touchsocket.net/
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. 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 is compatible. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.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 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETFramework 4.6.2
- TouchSocket.Http (>= 4.2.9)
- TouchSocket.SocketIo (>= 4.2.9)
-
.NETStandard 2.0
- TouchSocket.Http (>= 4.2.9)
- TouchSocket.SocketIo (>= 4.2.9)
-
.NETStandard 2.1
- TouchSocket.Http (>= 4.2.9)
- TouchSocket.SocketIo (>= 4.2.9)
-
net10.0
- TouchSocket.Http (>= 4.2.9)
- TouchSocket.SocketIo (>= 4.2.9)
-
net6.0
- TouchSocket.Http (>= 4.2.9)
- TouchSocket.SocketIo (>= 4.2.9)
-
net8.0
- TouchSocket.Http (>= 4.2.9)
- TouchSocket.SocketIo (>= 4.2.9)
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 |
|---|---|---|
| 4.2.9 | 84 | 5/10/2026 |