Dec 22, 2015
Building Real-Time Applications with ASP.NET SignalR
Brady Gaster
DEV-B343
SignalR is an abstraction that intelligently decides how to enable real-time over HTTP
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
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!
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.
Hubs
A real-time hit counter
Demo
Any sufficiently advanced technology is indistinguishable from magic - Arthur C. Clarke
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
Sending messages to all connected clients
Jon
Scott
BradyHub
Clients.All.doWork()
Sending messages to the calling client
Jon
Scott
BradyHub
Clients.Caller.doWork()
Sending messages to other connected clients
Jon
Scott
BradyHub
Clients.Others.doWork()
Sending messages to specific users
Jon
Scott
BradyHub
Clients.Users(“Brady”).doWork()
Real-time Web
SignalR with Angular
Demo
Damian’s MoveShape DemoDemo
My MoveShape Demo
Demo
Authorization with SignalR
Demo
Calling a SignalR Hub from the ServerDemo
Self-hosting SignalR using OWINDemo
Persistent Connections
Persistent SignalR ConnectionsLow levelWork on top of transport abstractionPass untyped messages using Send() and Broadcast()Client must parse message and know what to do
Persistent connections
Demo
Real-time Everywhere
Using SignalR’s Native .NET ClientDemo
Backplanes
Hubs are server-bound, so you’ll need to use a backplane if you’re running a web farm
How do Backplanes Work?What does SignalR do without a backplane?
Web Server B
Web Server A
How do Backplanes Work?Here’s how the Backplane solves the problem
Web Server A
Web Server B
Backplane
Using a SignalR Backplane
Demo
Thanks for your time, I hope you enjoyed the session and that you start partying with SignalR!
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!
http://signalr.net/
http://www.asp.net/signalr
http://blogs.msdn.com/b/webdev/
Track resources
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
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!
© 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.