you’re already a web site dev you’re interested in more simply making your web sites more...
TRANSCRIPT
![Page 1: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/1.jpg)
ASP.NET SignalR:Real-time Web for On-Time ApplicationsAnthony Clayton• .NET Senior Architect – Bennett Adelson@anthonyclayton [email protected]
![Page 2: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/2.jpg)
Who am I?
![Page 3: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/3.jpg)
Who are you?
![Page 4: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/4.jpg)
We’ll Discuss…
Core Concepts SignalR in action
(demos!) It’s only for the web,
right!?
![Page 5: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/5.jpg)
You’re already a Web Site Dev
You’re interested in more simply making your web sites more responsive
If you’re not already hosting sites in Windows Azure, what’s the value proposition? Ubiquitous & ready-to-go ecosystem Pre-made plumbing (security, data, etc) Pay as you go, use what you need
Assumptions
![Page 6: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/6.jpg)
SignalR is an abstraction that intelligently decides how to enable real-time over HTTP.
What is it?
![Page 7: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/7.jpg)
Currently using polling Client to client communication Dashboards and monitoring Collaboration Progress reporting Gaming
When would I use it?
![Page 8: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/8.jpg)
Durable messaging
When would I NOT use it?
![Page 9: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/9.jpg)
Server-side ASP.NET, self-hosted service
Client-side Web and others
Where does it fit in my application?
![Page 10: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/10.jpg)
Simplicity Reach Performance
Why should I use it?
![Page 11: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/11.jpg)
Simplicity
![Page 12: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/12.jpg)
Connection Represents a simple endpoint for sending single-recipient, grouped or
broadcast messages
Hub A more high-level pipeline built upon the Connections API that allows
your client and server to call methods on each other directly
Backplane Allows you to scale your application to multiple servers.
3 Core Concepts
![Page 13: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/13.jpg)
SignalR on Old-school Servers & ClientsWhen some lower-common denominator polling mechanism is neededWeb
Server
HTML
Client
Got Data?Got Data?
Got Data?
Got Data?
Got Data?Got Data?
Got Data?
Got Data?
Here’s some data
![Page 14: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/14.jpg)
SignalR on Modern Servers & ClientsWhen WebSockets or some other real-time layer is supportedWeb
Server
HTML
Client
Can you real-time?
YES!
Let’s do this!
![Page 15: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/15.jpg)
Demo – Connections
![Page 16: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/16.jpg)
The format of the actual message sent needs to be specified.
The developer prefers to work with a messaging and dispatching model rather than a remote invocation model.
An existing application that uses a messaging model is being ported to use SignalR.
Persistent Connections
![Page 17: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/17.jpg)
Demo – Hit Counter
![Page 18: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/18.jpg)
Create OWIN Startup class Create Hub class Create HTML file
Include JQuery and SignalR Javascript libraries Create connection Create Hub proxy Create client-side handlers Start the connection When connection is complete, wire up client-side events
Using a Hub - Steps
![Page 19: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/19.jpg)
More about 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 20: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/20.jpg)
Sending messages to all connected clients
Tom
John
SamHub
Clients.All.doWork()
![Page 21: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/21.jpg)
Sending messages to the calling client
Tom
John
SamHub
Clients.Caller.doWork()
![Page 22: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/22.jpg)
Sending messages to other connected clients
Tom
John
SamHub
Clients.Others.doWork()
![Page 23: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/23.jpg)
Sending messages to specific users
Tom
John
SamHub
Clients.Users(“Sam”).doWork()
![Page 24: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/24.jpg)
Demo – Move Shape
![Page 25: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/25.jpg)
Demo – Stock Ticker
![Page 26: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/26.jpg)
Reach
![Page 27: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/27.jpg)
Windows Server 2012 Windows Server 2008 r2 Windows 8 Windows 7 Windows Azure IIS 8 or IIS 8 Express, IIS 7 and 7.5.
Servers Supported
![Page 28: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/28.jpg)
Internet Explorer 8+ (Modern, Desktop, Mobile)
Chrome, Firefox, Safari (Windows and Mac) current version – 1
Opera – Windows only Android browser Windows Desktop (WinForms, WPF,
Silverlight) Windows Store Applications Windows Phone Xamarin platforms (iOS, Android)
Clients Supported
![Page 29: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/29.jpg)
JavaScript Client .NET Client
SignalR JavaScript & .NET Client Parity
![Page 30: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/30.jpg)
Demo – WinForms, WPF
![Page 31: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/31.jpg)
Security
![Page 32: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/32.jpg)
Allowing Authorized Users Only
![Page 33: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/33.jpg)
Controlling Access by Role
![Page 34: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/34.jpg)
Performance & Scale
![Page 35: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/35.jpg)
How do Backplanes Work?What does SignalR do without a backplane?
Web Server B
Web Server A
![Page 36: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/36.jpg)
How do Backplanes Work?Here’s how the Backplane solves the problem
Web Server A
Web Server B
Backplane
![Page 37: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/37.jpg)
Recap
![Page 39: You’re already a Web Site Dev You’re interested in more simply making your web sites more responsive If you’re not already hosting sites in](https://reader035.vdocuments.site/reader035/viewer/2022062802/56649e965503460f94b9a4ce/html5/thumbnails/39.jpg)
March .NET SIG3/10/2015Bennett Adelson Web Team
Lessons Applying Responsive Design to Our Company Website