PushRadar 3.1.0

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

// Install PushRadar as a Cake Tool
#tool nuget:?package=PushRadar&version=3.1.0                

PushRadar .NET Server Library

PushRadar is a realtime API service for the web. The service uses a simple publish-subscribe model, allowing you to broadcast "messages" on "channels" that are subscribed to by one or more clients. Messages are pushed in realtime to those clients.

This is PushRadar's official .NET server library.

Prerequisites

In order to use this library, please ensure that you have the following:

  • .NET Standard 2+
  • A PushRadar account - you can sign up at pushradar.com

Installation

The easiest way to get up and running is to install the library from NuGet. Run the following command in the Package Manager console:

$ Install-Package PushRadar

Broadcasting Messages

var radar = new PushRadar.PushRadar("your-secret-key");
radar.BroadcastAsync("channel-1", new Dictionary<string, object>() {
    { "message", "Hello world!" }
});

Receiving Messages

<script src="https://pushradar.com/js/v3/pushradar.min.js"></script>
<script>
    var radar = new PushRadar('your-public-key');
    radar.subscribe.to('channel-1', function (data) {
        console.log(data.message);
    });
</script>

Private Channels

Private channels require authentication and start with the prefix private-. We recommend that you use private channels by default to prevent unauthorised access to channels.

You will need to set up an authentication endpoint that returns a token using the Auth(...) method if the user is allowed to subscribe to the channel. For example:

var radar = new PushRadar.PushRadar("your-secret-key");
var channelName = HttpContext.Current.Request.QueryString["channelName"];
var socketID = HttpContext.Current.Request.QueryString["socketID"];

if (/* is user allowed to access channel? */ true) {
    var kvp = new KeyValuePair<string, object>("token", radar.Auth(channelName, socketID));
    return Json(kvp);
}

Then register your authentication endpoint by calling the auth(...) method client-side:

radar.auth('/auth');

Presence Channels

Presence channels require authentication and start with the prefix presence-. Presence channels are eligible for 'presence messages' containing information about channel subscribers.

You will need to set up an authentication endpoint as with private channels (see above). You should then register a onPresence(...) callback which will be called periodically. Your callback should accept two parameters: subscriber count and subscriber data. For example:

radar.auth('/auth');
radar.call.on.connection('/connected');

radar.subscribe.to('presence-channel-1', function (data) {
    console.log(data.message);
}).onPresence(function (count, clientData) {
    console.log(count);
});

If you wish to pass through subscriber (client) data, you can set up an endpoint and pass its URL to the call.on.connection(...) method. Your endpoint will be called when a user first connects to the service. From your endpoint you can register client data as follows:

var radar = new PushRadar.PushRadar("your-secret-key");
var socketID = HttpContext.Current.Request.Form["socketID"];
radar.RegisterClientDataAsync(socketID, new Dictionary<string, object>() {
    { "##uniqueID", 1 },
    { "name", "James Smith" }
});

Complete Documentation

Complete documentation for PushRadar's .NET server library can be found at: https://pushradar.com/docs/3.x/dotnet

License

Copyright © 2021, PushRadar. PushRadar's .NET server library is licensed under the MIT license: https://opensource.org/licenses/mit-license.php

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
3.1.0 446 4/6/2021
3.0.0 387 2/18/2021
3.0.0-alpha.1 191 2/9/2021
2.0.1 602 7/6/2019
2.0.0 596 7/4/2019
1.8.0 588 7/4/2019
1.0.1 1,030 8/21/2017
1.0.0 992 8/16/2017
0.9.0 1,043 8/13/2017

[NEW] Added support for client data registration