Dingtalk.Stream 1.0.3

dotnet add package Dingtalk.Stream --version 1.0.3
                    
NuGet\Install-Package Dingtalk.Stream -Version 1.0.3
                    
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="Dingtalk.Stream" Version="1.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Dingtalk.Stream" Version="1.0.3" />
                    
Directory.Packages.props
<PackageReference Include="Dingtalk.Stream" />
                    
Project file
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 Dingtalk.Stream --version 1.0.3
                    
#r "nuget: Dingtalk.Stream, 1.0.3"
                    
#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 Dingtalk.Stream@1.0.3
                    
#: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=Dingtalk.Stream&version=1.0.3
                    
Install as a Cake Addin
#tool nuget:?package=Dingtalk.Stream&version=1.0.3
                    
Install as a Cake Tool

Dingtalk Stream Mode .NET Unofficial SDK

钉钉 Stream 模式的非官方 .NET 实现。 Unofficial .NET implementation of Dingtalk stream mode.

它处理了认证、保活和推送事件的响应。 It handles the authentication, keep-alive and response of push event.

关于 Stream 模式 / About Stream Mode

钉钉文档链接: See Dingtalk doc here:

Stream Mode Doc

本 SDK 基于以下文档开发: This SDK was developed under the guide of doc:

Guide Doc

兼容性 / Compatibility

本包支持 .NET Standard 2.1。 This package supports .NET Standard 2.1.

使用方法 / Usage

using Dingtalk.Stream;
using System.Text.Json;

// 创建客户端实例 / Create client instance
var dingClient = OpenDingTalkStreamClientFactory.CreateClient("your appkey", "your appSecret");

// 同步处理事件 / Handle events synchronously
void ShowDocRaw(JsonDocument jsDoc)
{
    Console.WriteLine(jsDoc.RootElement.GetRawText());
}

// 异步处理事件 / Handle events asynchronously
async Task ShowDataInDoc(JsonDocument jsDoc)
{
    Console.WriteLine(jsDoc.RootElement.GetProperty("data").GetString());
}

// 建议使用异步方法,它不会阻塞 WebSocket 的持续推送数据
// It is recommended to use the asynchronous method, which will not block the continuous push data of WebSocket
dingClient.OnReceived += ShowDocRaw;
dingClient.OnReceivedAsync += ShowDataInDoc;

// 启动客户端 / Start the client
_ = dingClient.StartAsync();

Console.ReadLine();

// 停止客户端 / Stop the client
await dingClient.StopAsync();

ASP.NET Core 集成 / ASP.NET Core Integration

你可以通过依赖注入将客户端集成到 ASP.NET Core 应用中: You can also integrate the client into your ASP.NET Core application using dependency injection:

// 在 Program.cs 或 Startup.cs 中注册服务
// Register service in Program.cs or Startup.cs
builder.Services.AddDingTalkStream("your appkey", "your appSecret");

// 在你的控制器或服务中使用
// Use in your controller or service
public class YourService
{
    private readonly IOpenDingTalkStreamClient _client;

    public YourService(IOpenDingTalkStreamClient client)
    {
        _client = client;
    }

    public void SetupHandlers()
    {
        _client.OnReceived += ShowDocRaw;
        _client.OnReceivedAsync += ShowDataInDoc;
    }
}

客户端将在应用启动时自动启动,并在应用关闭时自动停止。 The client will be automatically started when your application starts and stopped when it shuts down.

注意事项 / Attention

目前仅支持事件推送,本 SDK 尚未实现回调推送。 Only event push supported now, this SDK doesn't implement callback push yet.

Product 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.  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 was computed.  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 netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen 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.

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.0.3 186 4/1/2025
1.0.2 270 8/31/2023
1.0.0 227 8/30/2023 1.0.0 is deprecated because it has critical bugs.