SignalR Overview

19
SignalR Overview: How Web Pages can get all the Real- time Fun?

Transcript of SignalR Overview

Page 1: SignalR Overview

SignalR Overview:

How Web Pages can get all the Real-

time Fun?

Page 2: SignalR Overview

• Overview of ASP.NET SignalR

• How SignalR can be used for realtime

communications

Agenda

Page 3: SignalR Overview

What is ASP.Net SignalR?

Real-time, persistent connection abstraction over HTTP

for .NET

Largest followed C# repo on GitHub

Simple and powerful API’s

Many techniques use to keep the logical connection up,

including retry logic if transports fail

Scale-out to web-farms using backplanes

Page 4: SignalR Overview

Here’s some data!

Page 5: SignalR Overview

Yeah, dude!

Page 6: SignalR Overview

SignalR Connections

Many techniques used to maintain connection

• WebSockets

• bidirectional stream

• Server Sent Events

• Push notifications from server to browser using DOM events

• Forever Frame

• uses HTTP 1.1 chunked encoding to establish a single long-lived

HTTP connection in a hidden iframe

• Internet Explorer only

• Long Polling

• hit the server hit the server hit the server hit the server hit server

and hope something comes back with data

Page 7: SignalR Overview

Clients

.NET

JavaScript

iOS

Hosts

ASP.NET

OWIN

Backplanes

SQL

Service Bus

Redis

Page 8: SignalR Overview

TransportInternet

Explorer

Chrome

(Windows or

iOS)

FirefoxSafari

(OSX or iOS)Android

WebSockets 10+ current - 1 current - 1 current - 1 N/A

Server-Sent

EventsN/A current - 1 current - 1 current - 1 N/A

ForeverFrame 8+ N/A N/A N/A 4.1

Long Polling 8+ current - 1 current - 1 current - 1 4.1

Page 9: SignalR Overview
Page 10: SignalR Overview

Web API

Controll

er

SignalR

Hub

Microsoft.AspNet.SignalR.GlobalHost.ConnectionManager.GetHubContext<MessageHub>()

.Clients.All.onMessageReceived(message);

Page 11: SignalR Overview

PersistentConnection And Hub

The two primary components in SignalR are hubs and

persistent connections.

Connection persistence is how the server can

communicate with one or more clients.

The vehicle to communicate with clients is a hub.

Page 12: SignalR Overview

Clients.All.doWork()Clients.Caller.doWork()Clients.Others.doWork()

Page 13: SignalR Overview

PersistentConnection

- Easiest implementation

- Has to have message type embed in the payload

to support different types of messages with different

payloads.

Hub – RPC over a connection

- Allows call methods on the client from the server

and from the server to the client

- Allows to pass strongly typed parameters to

methods

PersistentConnection Vs Hub

Page 14: SignalR Overview

Scale-Out

Web Nodes

Clients

Backplane

Page 15: SignalR Overview

Back

pla

ne

Page 16: SignalR Overview

Scale-Out

Three options for deploying backplane

- Service Bus

- SQL Server

- Redis

Open source in memory database that persists on disk

Requires libraries from the GitHub project currently not

in Microsoft SignalR

Page 17: SignalR Overview

SignalR Demo

Page 18: SignalR Overview

SignalR Examples

JabbR

http://jabbr.net

ShootR

http://shootr.signalr.net

Page 19: SignalR Overview

Resources

ASP.NET SignalR

http://signalr.net

http://www.asp.net/signalr

BUILD

http://www.buildwindows.com/

3-034 - Building Real-time Web Apps with ASP.NET SignalR