Git Product home page Git Product logo

blazorsignalr's Introduction

Obsolete

As of Blazor WebAssembly 3.2.0 Preview 1, the standard .NET SignalR client is now blazor compatible.

Please replace BlazorSignalR with Microsoft.AspNetCore.SignalR.Client and follow the standard configuration:

hubConnection = new HubConnectionBuilder()
            .WithUrl(NavigationManager.ToAbsoluteUri("/chatHub"))
            .Build();

BlazorSignalR Blazor=3.2.0-preview1 NuGet=BlazorSignalR

This package is a compatibility library for Microsoft ASP.NET Core SignalR to allow it to run on Microsoft ASP.NET Blazor.

The package is an addon for the existing .net client for SingalR, this is unlike the BlazorExtensions/SignalR package which emulates the c# api. This package instead works by replacing the transport mechanics, meaning the front facing SignalR api is still the standard .net one. The benefits of this setup is that as SignalR changes, this package takes little maintenance, as it only replaces the transport mechanisms, which are unlikely to change.

For more information about SignalR development, please check SignalR documentation.

Features

  • Uses standard SignalR Core .NET client
  • Allows multiple hub connections
  • Supports all transports (Long polling, Side side events and websockets)
  • Wide compatability (Automatic transport fallback ensure it works on all platforms)
  • Supports authentication

Install

Install the nuget package (or use the GUI in VS and search)

Install-Package BlazorSignalR

And then configure your connection creation like the following:

@inject IJSRuntime JsRuntime

HubConnection connection = new HubConnectionBuilder().WithUrlBlazor("/chathub", JsRuntime,
    options: opt => {
        opt.AccessTokenProvider = async () =>
        {
            return "some token for example";
        };
    }).Build();

Follow the official docs for the .NET core client.

Transports

All transports work

You will require browser support for WebSocket and EventSource for those transports to be enabled. You can install polyfils if you wish, as otherwise signalr will fallback to long polling.

You can manually select what transports and the implementations to use via Transports & Implementations in the BlazorHttpConnectionOptions when configuring the builder.

  • Long Polling (Implemented in C#)
  • Server Side Events (Implemented in JS, C# implementation waiting on Blazor bug)
  • Web Sockets (Implemented in JS, C# implementation waiting on mono support)

JS implemented means that the network requests are proxied to and from Javascript at a high level, whereas C# implemented means most of the processing occurs within the mono wasm runtime, with the low level networking being proxied back and forth. JS implementations should be faster as they use the underlying browser mechanisms.

Versions

Blazor BlazorSignalR
3.2.0-preview1 0.13.x
3.1.0-preview3 0.12.x
3.1.0-preview1 0.11.x
3.0.0-preview9 0.10.x
3.0.0-preview8 0.9.x
3.0.0-preview7 0.8.x
3.0.0-preview6 0.7.x
3.0.0-preview4 0.6.x
0.9.x 0.5.x
0.8.x 0.4.x
<= 0.7.x <= 0.3.x

The version of BlazorSignalR is tied lightly to the version of Blazor you are running. Generally the package is forwards compatible, however Blazor does have breaking changes once in a while, requiring a breaking BlazorSignalR version.

Alternatives

BlazorExtensions/SignalR

Uses the typescript client, exposed to C# via a shim api that relays back to typescript. This has the benefit of being extreemly reliable and fast, however at the expense of each feature needing to be hand exposed, meaning the api does not perfectly reflect the .net api.

This package uses the test suite from the BlazorExtensions/SignalR package and was based on their work. Please do check it out!

blazorsignalr's People

Contributors

catoleantruetschel avatar csnewman avatar luniclynx avatar regenhardt avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.