Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/BlazorExtensions/SignalR
SignalR Core support for Microsoft ASP.NET Core Blazor
https://github.com/BlazorExtensions/SignalR
blazor blazor-extensions blazor-interop signalr signalr-client signalr-core web-assembly webassembly
Last synced: 19 days ago
JSON representation
SignalR Core support for Microsoft ASP.NET Core Blazor
- Host: GitHub
- URL: https://github.com/BlazorExtensions/SignalR
- Owner: BlazorExtensions
- License: mit
- Created: 2018-05-23T18:02:09.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-07T02:23:59.000Z (almost 2 years ago)
- Last Synced: 2024-05-02T13:57:31.257Z (7 months ago)
- Topics: blazor, blazor-extensions, blazor-interop, signalr, signalr-client, signalr-core, web-assembly, webassembly
- Language: C#
- Homepage:
- Size: 1.24 MB
- Stars: 211
- Watchers: 12
- Forks: 48
- Open Issues: 23
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build](https://github.com/BlazorExtensions/SignalR/workflows/CI/badge.svg)](https://github.com/BlazorExtensions/SignalR/actions)
[![Package Version](https://img.shields.io/nuget/v/Blazor.Extensions.SignalR.svg)](https://www.nuget.org/packages/Blazor.Extensions.SignalR)
[![NuGet Downloads](https://img.shields.io/nuget/dt/Blazor.Extensions.SignalR.svg)](https://www.nuget.org/packages/Blazor.Extensions.SignalR)
[![License](https://img.shields.io/github/license/BlazorExtensions/SignalR.svg)](https://github.com/BlazorExtensions/SignalR/blob/master/LICENSE)> **DEPRECATION NOTE**: This package is no longer required since [Blazor WebAssembly now supports SignalR Client](https://devblogs.microsoft.com/aspnet/blazor-webassembly-3-2-0-preview-1-release-now-available/). Users of this package should stop using it and use the official client instead.
# Blazor Extensions
Blazor Extensions is a set of packages with the goal of adding useful features to [Blazor](https://blazor.net).
# Blazor Extensions SignalR
This package adds a [Microsoft ASP.NET Core SignalR](https://github.com/aspnet/SignalR) client library for [Microsoft ASP.NET Blazor](https://github.com/aspnet/Blazor).
The package aims to mimic the C# APIs of SignalR Client as much as possible and it is developed by wrapping the TypeScript client by using Blazor's interop capabilities.
For more information about SignalR development, please check [SignalR documentation](https://docs.microsoft.com/en-us/aspnet/core/signalr/introduction?view=aspnetcore-2.1).
# Features
This package implements all public features of SignalR Typescript client.
> Note: The _Streaming_ APIs are not implemented yet. We will add it soon.
# Sample usage
The following snippet shows how to setup the client to send and receive messages using SignalR.
The HubConnectionBuilder needs to get injected, which must be registered:
```c#
// in Startup.cs, ConfigureServices()
services.AddTransient();
```
```c#
// in Component class
[Inject]
private HubConnectionBuilder _hubConnectionBuilder { get; set; }
```
```c#
// in Component Initialization code
var connection = _hubConnectionBuilder // the injected one from above.
.WithUrl("/myHub", // The hub URL. If the Hub is hosted on the server where the blazor is hosted, you can just use the relative path.
opt =>
{
opt.LogLevel = SignalRLogLevel.Trace; // Client log level
opt.Transport = HttpTransportType.WebSockets; // Which transport you want to use for this connection
})
.Build(); // Build the HubConnectionconnection.On("Receive", this.Handle); // Subscribe to messages sent from the Hub to the "Receive" method by passing a handle (Func) to process messages.
await connection.StartAsync(); // Start the connection.await connection.InvokeAsync("ServerMethod", param1, param2, paramX); // Invoke a method on the server called "ServerMethod" and pass parameters to it.
var result = await connection.InvokeAsync("ServerMethod", param1, param2, paramX); // Invoke a method on the server called "ServerMethod", pass parameters to it and get the result back.
```# Contributions and feedback
Please feel free to use the component, open issues, fix bugs or provide feedback.
# Contributors
The following people are the maintainers of the Blazor Extensions projects:
- [Attila Hajdrik](https://github.com/attilah)
- [Gutemberg Ribiero](https://github.com/galvesribeiro)