Nesco.SignalRCommunicator.Core 1.0.1

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

Nesco.SignalRCommunicator.Core

Core library for SignalR-based client-server communication with support for large data transfer via file uploads.

Overview

This package contains the shared models, interfaces, and configuration options used by both the client and server packages.

Installation

dotnet add package Nesco.SignalRCommunicator.Core

What's Included

Models

  • SignalRResponse: Standardized response object for method invocations

    • Supports multiple response types: JsonObject, FilePath, Null, Error
    • Handles both direct data transmission and file-based transfers for large data
  • SignalRResponseType: Enum defining response types

Interfaces

  • IMethodExecutor: Contract for executing methods on the client side

    • Implement this interface to route method calls to your business logic
  • IFileUploadService: Contract for uploading large response data

    • Implement for custom storage solutions (cloud, network shares, etc.)
  • IFileReaderService: Contract for reading uploaded files on the server

    • Implement for custom file retrieval logic

Options

  • SignalRClientOptions: Configuration for client behavior

    • Server URL and hub path
    • Timeouts and retry logic
    • Maximum direct data size threshold
  • SignalRServerOptions: Configuration for server behavior

    • Maximum concurrent requests
    • Request timeout
    • Automatic file cleanup

Response Types Explained

JsonObject

Used when the response data is small enough to be sent directly through SignalR (default: ≤10KB).

var response = new SignalRResponse
{
    ResponseType = SignalRResponseType.JsonObject,
    JsonData = myDataObject
};

FilePath

Used when the response data exceeds the size threshold. Data is uploaded to a file, and the path is returned.

var response = new SignalRResponse
{
    ResponseType = SignalRResponseType.FilePath,
    FilePath = "/uploads/temp/result_abc123.json"
};

Null

Used when a method returns null or no data.

var response = new SignalRResponse
{
    ResponseType = SignalRResponseType.Null
};

Error

Used when an error occurs during method execution.

var response = new SignalRResponse
{
    ResponseType = SignalRResponseType.Error,
    ErrorMessage = "Failed to process request: Database connection timeout"
};

Implementing IMethodExecutor

The method executor is responsible for routing method calls to your business logic:

public class MyMethodExecutor : IMethodExecutor
{
    private readonly IMyService _myService;

    public MyMethodExecutor(IMyService myService)
    {
        _myService = myService;
    }

    public async Task<object?> ExecuteAsync(string methodName, object? parameter)
    {
        return methodName switch
        {
            "GetUserData" => await _myService.GetUserData(ConvertParameter<int>(parameter)),
            "UpdateSettings" => await _myService.UpdateSettings(ConvertParameter<SettingsDto>(parameter)),
            "ProcessOrder" => await _myService.ProcessOrder(ConvertParameter<OrderDto>(parameter)),
            _ => throw new NotSupportedException($"Method '{methodName}' is not supported")
        };
    }

    private T ConvertParameter<T>(object? parameter)
    {
        if (parameter is JsonElement jsonElement)
        {
            return JsonSerializer.Deserialize<T>(jsonElement.GetRawText())!;
        }

        if (parameter is T directCast)
        {
            return directCast;
        }

        var json = JsonSerializer.Serialize(parameter);
        return JsonSerializer.Deserialize<T>(json)!;
    }
}

Thread Safety

All models and options are designed to be thread-safe when used as intended. The response handling mechanism uses concurrent collections to manage multiple simultaneous requests.

License

MIT License - see LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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.
  • net10.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Nesco.SignalRCommunicator.Core:

Package Downloads
Nesco.SignalRCommunicator.Client

Client library for SignalR-based communication. Connect to a SignalR server, receive method invocations, and return responses with automatic large data handling.

Nesco.SignalRCommunicator.Server

Server library for SignalR-based communication. Invoke methods on connected clients and receive responses with automatic large data handling.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 161 11/28/2025
1.0.0 202 11/28/2025