Top Banner
38

SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.

Dec 22, 2015

Download

Documents

Rosaline French
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.
Page 2: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.

Building Real-Time Applications with ASP.NET SignalR

Brady Gaster

DEV-B343

Page 3: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.
Page 4: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.

SignalR is an abstraction that intelligently decides how to enable real-time over HTTP

Page 5: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.

SignalR on Old-school Servers & ClientsWhen some lower-common denominator polling mechanism is needed

Web

Serv

er H

TM

L C

lien

t

Got Data?

Got Data?

Got Data?

Got Data?

Got Data?

Got Data?

Got Data?

Got Data?

Here’s some data

Page 6: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.

SignalR on Modern Servers & ClientsWhen WebSockets or some other real-time layer is supported

Web

Serv

er H

TM

L C

lien

tI can party in real time. Can you?

Yep, I can party in real time

Let’s party in real time!

Page 7: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.

SignalR Core Concepts

Hub

• A more high-level pipeline built upon the Connection API that allows your client and server to call methods on each other directly

Connection

• Represents a simple endpoint for sending single-recipient, grouped, or broadcast messages

Backplane

• A backplane allows you to scale your application to multiple servers. With a backplane enabled, each application instance sends messages to the backplane, and the backplane forwards them to the other application instances.

Page 8: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.

Hubs

Page 9: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.

A real-time hit counter

Demo

Page 10: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.

Any sufficiently advanced technology is indistinguishable from magic - Arthur C. Clarke

Page 11: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.

SignalR Hubs

A hub is a .NET class that inherits fromMicrosoft.AspNet.SignalR.Hub

Since Hubs are called on the client by name, the name can be customized if needed

The Clients property of a Hub class exposes dynamic properties useful for targeting specific clientsHub classes also have virtual methods useful for responding to connected/disconnected events

Page 12: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.

Sending messages to all connected clients

Jon

Scott

BradyHub

Clients.All.doWork()

Page 13: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.

Sending messages to the calling client

Jon

Scott

BradyHub

Clients.Caller.doWork()

Page 14: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.

Sending messages to other connected clients

Jon

Scott

BradyHub

Clients.Others.doWork()

Page 15: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.

Sending messages to specific users

Jon

Scott

BradyHub

Clients.Users(“Brady”).doWork()

Page 16: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.

Real-time Web

Page 17: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.

SignalR with Angular

Demo

Page 18: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.

Damian’s MoveShape DemoDemo

Page 19: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.

My MoveShape Demo

Demo

Page 20: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.

Authorization with SignalR

Demo

Page 21: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.

Calling a SignalR Hub from the ServerDemo

Page 22: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.

Self-hosting SignalR using OWINDemo

Page 23: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.

Persistent Connections

Page 24: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.

Persistent SignalR ConnectionsLow levelWork on top of transport abstractionPass untyped messages using Send() and Broadcast()Client must parse message and know what to do

Page 25: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.

Persistent connections

Demo

Page 26: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.

Real-time Everywhere

Page 27: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.

Using SignalR’s Native .NET ClientDemo

Page 28: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.

Backplanes

Page 29: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.

Hubs are server-bound, so you’ll need to use a backplane if you’re running a web farm

Page 30: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.

How do Backplanes Work?What does SignalR do without a backplane?

Web Server B

Web Server A

Page 31: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.

How do Backplanes Work?Here’s how the Backplane solves the problem

Web Server A

Web Server B

Backplane

Page 32: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.

Using a SignalR Backplane

Demo

Page 33: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.

Thanks for your time, I hope you enjoyed the session and that you start partying with SignalR!

Page 34: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.

DEV-B219 Latest Innovations for ASP.NET MVC Development

DEV-B344 The Future of Microsoft .NET on the Server

DEV-H215 Real-Time Web Applications with Microsoft ASP.NET SignalR

DEV-B318 Best Practices for Scaling Web Apps

Related content

Find Me Later!

Page 35: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.

http://signalr.net/

http://www.asp.net/signalr

http://blogs.msdn.com/b/webdev/

Track resources

Page 36: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.

Resources

Learning

Microsoft Certification & Training Resources

www.microsoft.com/learning

Developer Network

http://developer.microsoft.com

TechNet

Resources for IT Professionals

http://microsoft.com/technet

Sessions on Demand

http://channel9.msdn.com/Events/TechEd

Page 37: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.

TechEd Mobile app for session evaluations is currently offline

SUBMIT YOUR TECHED EVALUATIONSFill out an evaluation via

CommNet Station/PC: Schedule Builder

LogIn: europe.msteched.com/catalog

We value your feedback!

Page 38: SignalR on Old-school Servers & Clients When some lower-common denominator polling mechanism is needed Web Server HTML Client Got Data? Here’s some.

© 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.