GithubHelp home page GithubHelp logo

codesee / signalr.orleans Goto Github PK

View Code? Open in Web Editor NEW

This project forked from orleanscontrib/signalr.orleans

0.0 2.0 0.0 92 KB

SignalR backend based on Orleans.

License: MIT License

C# 100.00%

signalr.orleans's Introduction

SignalR.Orleans

SignalR.Orleans

Build status NuGet Gitter

Orleans is a framework that provides a straight-forward approach to building distributed high-scale computing applications, without the need to learn and apply complex concurrency or other scaling patterns.

ASP.NET Core SignalR is a new library for ASP.NET Core developers that makes it incredibly simple to add real-time web functionality to your applications. What is "real-time web" functionality? It's the ability to have your server-side code push content to the connected clients as it happens, in real-time.

SignalR.Orleans is a package that allow us to enhance the real-time capabilities of SignalR by leveraging Orleans distributed cloud platform capabilities.

Installation

Installation is performed via NuGet

From Package Manager:

PS> Install-Package SignalR.Orleans -prerelease

.Net CLI:

# dotnet add package SignalR.Orleans -prerelease

Paket:

# paket add SignalR.Orleans -prerelease

Configuration

Silo

We need to configure the Orleans Silo with the below:

  • Use .UseSignalR() on ISiloHostBuilder.

Example

var siloPort = 11111;
int gatewayPort = 30000;
var siloAddress = IPAddress.Loopback;

var silo = new SiloHostBuilder()
    .UseSignalR()
    .Build();
await silo.StartAsync();

Client

Now your SignalR application needs to connect to the Orleans Cluster by using an Orleans Client:

  • Use .UseSignalR() on IClientBuilder.

Example

var client = new ClientBuilder()
    .UseSignalR()
    .Build();
    await client.Connect();

Somewhere in your Startup.cs:

  • Use .AddSignalR() on IServiceCollection (this is part of Microsoft.AspNetCore.SignalR nuget package).
  • Use AddOrleans() on .AddSignalR().

Example

public void ConfigureServices(IServiceCollection services)
{
    ...
    services
        .AddSignalR()
        .AddOrleans();
    ...
}

Great! Now you have SignalR configured and Orleans SignalR backplane built in Orleans!

Features

Hub Context

HubContext gives you the ability to communicate with the client from orleans grains (outside the hub).

Sample usage: Receiving server push notifications from message brokers, web hooks, etc. Ideally first update your grain state and then push signalr message to the client.

Example:

public class UserNotificationGrain : Grain<UserNotificationState>, IUserNotificationGrain
{
	private HubContext<IUserNotificationHub> _hubContext;

	public override async Task OnActivateAsync()
	{
		_hubContext = GrainFactory.GetHub<IUserNotificationHub>();
		// some code...
		await _hubContext.User(this.GetPrimaryKeyString()).SendSignalRMessage("Broadcast", State.UserNotification);
	}
}

Contributions

PRs and feedback are very welcome!

signalr.orleans's People

Contributors

galvesribeiro avatar claylaut avatar darkcow avatar jonathansant avatar larsfjerm avatar

Watchers

James Cloos avatar Zhiyong Peng avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.