SignalR.Azure.Serverless 1.0.1

dotnet add package SignalR.Azure.Serverless --version 1.0.1                
NuGet\Install-Package SignalR.Azure.Serverless -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="SignalR.Azure.Serverless" Version="1.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SignalR.Azure.Serverless --version 1.0.1                
#r "nuget: SignalR.Azure.Serverless, 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.
// Install SignalR.Azure.Serverless as a Cake Addin
#addin nuget:?package=SignalR.Azure.Serverless&version=1.0.1

// Install SignalR.Azure.Serverless as a Cake Tool
#tool nuget:?package=SignalR.Azure.Serverless&version=1.0.1                

SignalR.Azure.Serverless

A helper library for publishing and subscribing to SignalR service running on Azure in serverless mode.

With SignalR serverless, you can publish and subscribe to messages without the need to create an ASP.NET Core API App. You may use this library in ASP.NET Core, Xamarin, WinForm, WPF, or Console applications. Unlike SNS or Azure Event Grid, any app can subscribe to the feed (and publish) so long as the app knows the AccessKey.

SignalR is not a queue, it's an opportunistic broadcaster. SignalR will broadcast an event to whichever clients are connected to the hub at the time of the event. Any clients which are not connected will miss the event. Sometimes this behaviour is desired.

There are two samples: A WFP App RestaurantTableTracker and a PubSubConsoleApp. See the WPF App for an example on how to handle connection drops.

Sample

public class PubSubSample
{
    SignalRHubHelper signalRHubHelper;
    HubConnection signalRHubConnection;

    public async Task ListenToEvents(string connString)
    {
        signalRHubHelper = new SignalRHubHelper(connString);

        var hubUrl = signalRHubHelper.ClientUrl("default_hub");

        // define a connection to receive published events
        signalRHubConnection = new HubConnectionBuilder().WithUrl(hubUrl, option =>
        {
            option.AccessTokenProvider = () =>
            {
                var token = signalRHubHelper.GenerateAccessToken(hubUrl, "user-x");

                return Task.FromResult(token);
            };
        }).Build();

        // define an event handler for received messages
        signalRHubConnection.On<string, string>("StatusChanged", (deviceId, status) =>
        {
            Console.WriteLine($"Device {deviceId} changed status to {status}");
        });

        // start listening to published events
        await signalRHubConnection.StartAsync();

        Console.WriteLine("Listening for events...");
    }

    public async Task PublishTestMessage()
    {
        using (var httpClient = new HttpClient()) // it is recommened that you re-use the HttpClient
        {
            var signalRApiClient = new SignalRApiClient(httpClient, signalRHubHelper);

            var msg = new SignalRMessage()
            {
                target = "StatusChanged",
                arguments = new object[] { "device_1", "offline" }
            };

            await signalRApiClient.BroadcastToAllClients(senderUserId: "user-x", hubName: "default_hub", msg);
        }
    }

    public async Task StopListeningToEvents()
    {
        await signalRHubConnection.DisposeAsync();
    }
}

The code is based on samples published by Jeeva Subburaj and is written against v1 of SignalR API.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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.1 1,446 7/1/2019

v1.0.1 - Initial Release