PushRadar 3.1.0

PushRadar's official .NET server library

Install-Package PushRadar -Version 3.1.0
dotnet add package PushRadar --version 3.1.0
<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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: PushRadar, 3.1.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. 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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

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

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

Release Notes

[NEW] Added support for client data registration

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
3.1.0 26 4/6/2021
3.0.0 37 2/18/2021
3.0.0-alpha.1 37 2/9/2021
2.0.1 256 7/6/2019
2.0.0 230 7/4/2019
1.8.0 222 7/4/2019
1.0.1 566 8/21/2017
1.0.0 541 8/16/2017
0.9.0 543 8/13/2017