SignalRChatClient 1.1.10
dotnet add package SignalRChatClient --version 1.1.10
NuGet\Install-Package SignalRChatClient -Version 1.1.10
<PackageReference Include="SignalRChatClient" Version="1.1.10" />
paket add SignalRChatClient --version 1.1.10
#r "nuget: SignalRChatClient, 1.1.10"
// Install SignalRChatClient as a Cake Addin #addin nuget:?package=SignalRChatClient&version=1.1.10 // Install SignalRChatClient as a Cake Tool #tool nuget:?package=SignalRChatClient&version=1.1.10
CP.AspNetCore.SignalR.Client.Rx
Microsoft.AspNetCore.SignalR.Client 的响应式扩展
安装
Install-Package CP.AspNetCore.SignalR.Client.Rx
用法
using CP.AspNetCore.SignalR.Client.Rx;
var connection = new HubConnectionBuilder()
.WithUrl("http://localhost:5000/hub")
.AutoReconnect()
.Build();
var sub = connection.On<string>("Stream").Subscribe(Console.WriteLine);
var con = connection.StartAsync().Subscribe();
其他选项
HubBuilder.Create(builder => builder.WithUrl("https://localhost:53933/ChatHub"))
.Subscribe(x =>
{
var connection = x.hubConnection;
x.disposables.Add(connection.On<string, string>("ReceiveMessage").Subscribe(responce => Dispatcher.Invoke(() =>
{
var newMessage = $"{responce.t1}: {responce.t2}";
messagesList.Items.Add(newMessage);
})));
x.disposables.Add(connection.HasClosed().Subscribe(error => Dispatcher.Invoke(() =>
{
connectButton.IsEnabled = true;
sendButton.IsEnabled = false;
messagesList.Items.Add(error);
})));
x.disposables.Add(connectButton.Events().Click.Start(connection).Subscribe(_ => Dispatcher.Invoke(() =>
{
try
{
messagesList.Items.Add("Connection started");
connectButton.IsEnabled = false;
sendButton.IsEnabled = true;
}
catch (Exception ex)
{
messagesList.Items.Add(ex.Message);
}
})));
x.disposables.Add(sendButton.Events().Click.Subscribe(_ => Dispatcher.Invoke(async () =>
{
try
{
await connection.InvokeAsync("SendMessage", userTextBox.Text, messageTextBox.Text);
}
catch (Exception ex)
{
messagesList.Items.Add(ex.Message);
}
})));
});
可用运算符
On<T>(string methodName)
On<T1, T2>(string methodName)
On<T1, T2, T3>(string methodName)
On<T1, T2, T3, T4>(string methodName)
On<T1, T2, T3, T4, T5>(string methodName)
On<T1, T2, T3, T4, T5, T6>(string methodName)
On<T1, T2, T3, T4, T5, T6, T7>(string methodName)
On<T1, T2, T3, T4, T5, T6, T7, T8>(string methodName)
HasClosed()
HasReconnected()
IsReconnecting()
StartObservable()
StartObservable(CancellationToken cancellationToken)
Start()
Start(CancellationToken cancellationToken)
Start(HubConnection connection)
Start(HubConnection connection, CancellationToken cancellationToken)
StopObservable()
StreamObservable()
InvokeAsync(string methodName, params object[] args)
HubBuilder.Create(builder => // Configure Builder)
产品 | 版本 兼容和额外的目标框架版本。 |
---|---|
.NET | net6.0-windows7.0 兼容。 |
-
net6.0-windows7.0
- CP.AspNetCore.SignalR.Client.Rx (>= 1.1.10)
- ReactiveMarbles.ObservableEvents.SourceGenerator (>= 1.3.1)
NuGet 包
此包没有被任何 NuGet 包使用。
GitHub 仓库
此包没有被任何流行的 GitHub 仓库使用。
与 Net 6 / 7 和 net462 的兼容性