BlazorSignalProxyServices.Client 1.0.0

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

BlazorSignalProxyServices

A set of libraries that enable seamless proxy method calls between Blazor Server and Blazor WebAssembly applications using SignalR connections. This library provides a transparent way to invoke methods on services from the client side as if they were local calls, while the actual execution happens on the server.

Packages

Package NuGet Version Description
BlazorSignalProxyServices.Core NuGet Core models, settings, and shared functionality
BlazorSignalProxyServices.Client NuGet Client-side proxy services for Blazor WebAssembly
BlazorSignalProxyServices.Server NuGet Server-side SignalR hub and services

Features

  • Transparent Method Proxying: Call server methods from client as if they were local
  • Real-time Communication: Built on top of SignalR for bi-directional communication
  • Async Support: Full support for asynchronous method calls with configurable timeouts
  • Type-Safe: Strongly typed interfaces ensure compile-time safety
  • Configurable: Settings for both client and server components
  • Modular: Separate packages for Core, Client, and Server functionality

Quick Start

Server Setup (Blazor Server / ASP.NET Core)

  1. Install the server package:
dotnet add package BlazorSignalProxyServices.Server
  1. Configure services in Program.cs:
using BlazorSignalProxyServices.Server;

var builder = WebApplication.CreateBuilder(args);

// Add SignalR Proxy services
builder.Services.AddSignalProxyServer();

var app = builder.Build();

// Configure SignalR Proxy
app.UseSignalProxyServer();

app.Run();

Client Setup (Blazor WebAssembly)

  1. Install the client package:
dotnet add package BlazorSignalProxyServices.Client
  1. Configure services in Program.cs:
using BlazorSignalProxyServices.Client;

var builder = WebAssemblyHostBuilder.CreateDefault(args);

// Add SignalR Proxy client services
var proxyClient = builder.Services.AddSignalProxyClient();

// Register your service interfaces for proxying
proxyClient.AddProxyService<IMyService>();

await builder.Build().RunAsync();
  1. Use proxied services in components:
@inject IMyService MyService

@code {
    private async Task CallServerMethod()
    {
        // This call will be proxied to the server via SignalR
        var result = await MyService.GetDataAsync();
    }
}

Architecture

┌─────────────────────┐    SignalR     ┌─────────────────────┐
│ Blazor WebAssembly  │◄──────────────►│   Blazor Server     │
│                     │                │                     │
│ ┌─────────────────┐ │                │ ┌─────────────────┐ │
│ │ Proxy Client    │ │   Method Call  │ │ SignalR Hub     │ │
│ │ (Dynamic Proxy) │ ├────────────────┤ │ (Dispatcher)    │ │
│ └─────────────────┘ │                │ └─────────────────┘ │
│                     │                │          │          │
└─────────────────────┘                │          ▼          │
                                       │ ┌─────────────────┐ │
                                       │ │ Actual Service  │ │
                                       │ │ Implementation  │ │
                                       │ └─────────────────┘ │
                                       └─────────────────────┘

How It Works

  1. Service Registration: Register your service interfaces with the proxy client
  2. Dynamic Proxy Creation: The library creates dynamic proxies for your service interfaces using Castle.DynamicProxy
  3. Method Interception: When you call a method on the proxy, it's intercepted and converted into a ProxyFunctionInvokeRequest
  4. SignalR Communication: The request is sent to the server via SignalR connection
  5. Server Execution: The server hub receives the request and invokes the actual service method
  6. Response Handling: The result is sent back to the client and returned from the proxy method

Configuration

Client Settings

var clientSettings = new SignalProxyClientSettings
{
    DefaultAsyncTimeout = TimeSpan.FromSeconds(30),
    HubUrl = "/signalproxyhub"
};

builder.Services.AddSignalProxyClient(clientSettings);

Server Settings

var serverSettings = new SignalProxyServerSettings
{
    UseResponseCompression = true,
    HubPath = "/signalproxyhub"
};

builder.Services.AddSignalProxyServer(serverSettings);

Advanced Usage

Custom Interceptors

You can create custom interceptors by implementing the appropriate interfaces:

public class CustomInterceptor : IAsyncInterceptor
{
    public void InterceptSynchronous(IInvocation invocation)
    {
        // Custom synchronous interception logic
    }

    public void InterceptAsynchronous(IInvocation invocation)
    {
        // Custom asynchronous interception logic
    }

    public void InterceptAsynchronous<TResult>(IInvocation invocation)
    {
        // Custom generic asynchronous interception logic
    }
}

Error Handling

The library includes built-in error handling and timeout management. Failed method calls will throw exceptions on the client side, maintaining the expected behavior of local method calls.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Requirements

  • .NET 8.0 or later
  • ASP.NET Core (for server-side)
  • Blazor WebAssembly (for client-side)

Dependencies

Core

  • Castle.Core.AsyncInterceptor
  • Microsoft.Extensions.DependencyInjection.Abstractions

Client

  • Microsoft.AspNetCore.Components.WebAssembly
  • Microsoft.AspNetCore.SignalR.Client
  • BlazorSignalProxyServices.Core

Server

  • Microsoft.AspNetCore.Components.WebAssembly.Server
  • BlazorSignalProxyServices.Core

License

This project is licensed under the MIT License - see the LICENSE file for details.

Changelog

Version 1.0.0

  • Initial release
  • Core proxy functionality
  • Client and server packages
  • SignalR-based communication
  • Async method support
  • Configurable timeouts
Product Compatible and additional computed target framework versions.
.NET 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 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. 
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.0 165 8/6/2025