SlideShare a Scribd company logo
SignalR and ASP.NET
                           Welcome to the Real-Time Web




Tuesday, March 26, 13
Who am I?
  I am a Microsoft Certified Solution Developer and I’ve
  been developing software since 1979. Since 2009, I have
  been focused on developing mobile applications, for 
  iPhone, Android, the mobile web, and Windows Phone 7.




Tuesday, March 26, 13
Free mobile tutorials with source
                        code @ therockncoder.blogspot.com




Tuesday, March 26, 13
Want more? Follow me, new tutorials are
                    announced on Twitter first:
                         @therockncoder




Tuesday, March 26, 13
Source code for my tutorials hosted on
                                        GitHub @
                            https://github.com/Rockncoder




Tuesday, March 26, 13
Check out my videos:
                 www.youtube.com/rockncoder




Tuesday, March 26, 13
Our Agenda
                    • A Brief History of the Web
                    • What is ASP.NET SignalR?
                    • Under the Hood
                    • Building DIRTy Apps
                    • Debugging
                    • Handling Success
Tuesday, March 26, 13
A Brief History of Web

                    • 1990’s - The Static Web
                    • 2000’s - The Age of Ajax
                    • 2010’s - The Real-Time Web


Tuesday, March 26, 13
1990’s - The Static Web

                    • HTML versions 2.0 - 4.01
                     • (There never was a version 1.0)
                    • Request/Response


Tuesday, March 26, 13
2000’s - The Age of Ajax

                    • XMLHttpRequest object
                    • Prototype
                    • jQuery


Tuesday, March 26, 13
2010’s - The Real-Time
                             Web

                    • Comet
                    • WebSocket
                    • Real-Time Libraries


Tuesday, March 26, 13
Comet
                    • Holding open an HTTP connection via a
                        variety of techniques like...
                        • Hidden IFrame
                        • Periodic Polling
                        • Long Polling
                        • Lots of Plumbing
Tuesday, March 26, 13
What is SPDY?

                    • An open network protocol
                    • Developed by Google
                    • Goal is to reduce page load time
                    • Does not replace HTTP
                    • Modifies HTTP for performance

Tuesday, March 26, 13
WebSocket

                    • Full-duplex communication over a single
                        TCP connection
                    • Port 80 or 443
                    • A low level protocol
                    • Great, but no backwards compatibility

Tuesday, March 26, 13
Real-Time Libraries

                    • Cramp
                    • django-sse
                    • sse
                    • Socket.io/Now.js
                    • SignalR

Tuesday, March 26, 13
What is ASP.NET
                               SignalR?

                            ASP.NET SignalR is a new library for
                        ASP.NET developers that makes it incredibly
                        simple to add real-time web functionality to
                                     your applications.




Tuesday, March 26, 13
ASP.NET SignalR
                    • Create as an open source project by two
                        Microsoft employees: David Fowler &
                        Damien Edwards
                    • Adopted by Microsoft, but remains open
                        source - source is on GitHub
                    • Like jQuery for communications
                    • Distributed via NuGet
Tuesday, March 26, 13
Under the Hood

                    • WebSockets
                    • Server Sent Events, Event Source
                    • Forever Frame (IE only)
                    • Ajax long polling
                    • Only WebSockets is true full duplex

Tuesday, March 26, 13
Installing SignalR

                    • The project exists on GitHub but
                    • NuGet is the best way to install it
                     • Install Microsoft ASP.NET SignalR


Tuesday, March 26, 13
What’s in the Package?

                    • SignalR Core - Server side stuff
                    • SignalR JS - JavaScript library
                    • SignalR Owin - An OWIN adapter
                    • SignalR SystemWeb - To host on IIS

Tuesday, March 26, 13
Other Packages
                    • SignalR Client - .NET client
                    • SignalR Sample - A fake stock ticker
                    • LCSK - Live chat app
                    • SignalR.EventStream - Monitor your site
                    • ElmahR.Elmah - ELMAH
                    • and lots more
Tuesday, March 26, 13
What is OWIN?
                    • Open Web Interface for .NET
                    • A specification for the communication
                        between .NET Web Server and Web App
                    • IIS isn’t the only .NET Web Server, there is
                        HttpListener, server.dll, Kayak, and
                        potentially others
                    • SignalR depends on OWIN for hosting
Tuesday, March 26, 13
What’s It Good For?
                    • dashboards
                    • monitoring
                    • collaborative anything
                    • job progress
                    • real-time forms
                    • gaming...
Tuesday, March 26, 13
http://shootr.signalr.net



Tuesday, March 26, 13
https://jabbr.net



Tuesday, March 26, 13
Building DIRTy Apps

                    • Data Intensive Real-Time(y) Apps
                    • Two main classes:
                     • PersistentConnections
                     • Hubs

Tuesday, March 26, 13
Connections

                    • The raw connection in SignalR
                    • Can connect with 1 - n clients
                    • Is an IHTTP handler
                    • Requires route to be defined
                    • Limited to sending message

Tuesday, March 26, 13
Connection Demo



Tuesday, March 26, 13
Hubs

                    • Built on top of PersistentConnection
                    • Can connect with 1 - n clients
                    • Routes automatically mapped
                    • Can send messages and call methods
                    • SignalR defines the protocol

Tuesday, March 26, 13
Hub Demo



Tuesday, March 26, 13
Debugging


                    • With Chrome
                    • With Fiddler


Tuesday, March 26, 13
Clients
                    • JavaScript (as a jQuery plugin)
                    • .NET 4.0/4.5
                    • Silverlight 5
                    • Windows Store Apps
                    • iOS (community)
                    • MonoTouch (community)
Tuesday, March 26, 13
Clients
                    • Windows Phone 8
                    • MonoTouch (official)
                    • MonoDroid (official)
                    • iOS (official)
                    • .NET Micro Framework
                    • Java
Tuesday, March 26, 13
Handling Success

                    • Scale-out via the backplane
                    • Azure ServiceBus
                    • Redis
                    • SQL Server

Tuesday, March 26, 13
Gotchas

                    • Documentation is limited
                    • Documentation may be out of date
                    • But finally a released product!


Tuesday, March 26, 13
Resources

                    • http://signalr.net/
                    • https://jabbr.net
                    • https://github.com/SignalR/SignalR/wiki
                    • http://www.asp.net/signalr/overview/getting-
                        started/tutorial-getting-started-with-signalr



Tuesday, March 26, 13
Summary


                        ASP.NET SignalR makes it incredibly easy to
                        add real-time capabilities to your web app.




Tuesday, March 26, 13

More Related Content

SignalR

  • 1. SignalR and ASP.NET Welcome to the Real-Time Web Tuesday, March 26, 13
  • 2. Who am I? I am a Microsoft Certified Solution Developer and I’ve been developing software since 1979. Since 2009, I have been focused on developing mobile applications, for  iPhone, Android, the mobile web, and Windows Phone 7. Tuesday, March 26, 13
  • 3. Free mobile tutorials with source code @ therockncoder.blogspot.com Tuesday, March 26, 13
  • 4. Want more? Follow me, new tutorials are announced on Twitter first: @therockncoder Tuesday, March 26, 13
  • 5. Source code for my tutorials hosted on GitHub @ https://github.com/Rockncoder Tuesday, March 26, 13
  • 6. Check out my videos: www.youtube.com/rockncoder Tuesday, March 26, 13
  • 7. Our Agenda • A Brief History of the Web • What is ASP.NET SignalR? • Under the Hood • Building DIRTy Apps • Debugging • Handling Success Tuesday, March 26, 13
  • 8. A Brief History of Web • 1990’s - The Static Web • 2000’s - The Age of Ajax • 2010’s - The Real-Time Web Tuesday, March 26, 13
  • 9. 1990’s - The Static Web • HTML versions 2.0 - 4.01 • (There never was a version 1.0) • Request/Response Tuesday, March 26, 13
  • 10. 2000’s - The Age of Ajax • XMLHttpRequest object • Prototype • jQuery Tuesday, March 26, 13
  • 11. 2010’s - The Real-Time Web • Comet • WebSocket • Real-Time Libraries Tuesday, March 26, 13
  • 12. Comet • Holding open an HTTP connection via a variety of techniques like... • Hidden IFrame • Periodic Polling • Long Polling • Lots of Plumbing Tuesday, March 26, 13
  • 13. What is SPDY? • An open network protocol • Developed by Google • Goal is to reduce page load time • Does not replace HTTP • Modifies HTTP for performance Tuesday, March 26, 13
  • 14. WebSocket • Full-duplex communication over a single TCP connection • Port 80 or 443 • A low level protocol • Great, but no backwards compatibility Tuesday, March 26, 13
  • 15. Real-Time Libraries • Cramp • django-sse • sse • Socket.io/Now.js • SignalR Tuesday, March 26, 13
  • 16. What is ASP.NET SignalR? ASP.NET SignalR is a new library for ASP.NET developers that makes it incredibly simple to add real-time web functionality to your applications. Tuesday, March 26, 13
  • 17. ASP.NET SignalR • Create as an open source project by two Microsoft employees: David Fowler & Damien Edwards • Adopted by Microsoft, but remains open source - source is on GitHub • Like jQuery for communications • Distributed via NuGet Tuesday, March 26, 13
  • 18. Under the Hood • WebSockets • Server Sent Events, Event Source • Forever Frame (IE only) • Ajax long polling • Only WebSockets is true full duplex Tuesday, March 26, 13
  • 19. Installing SignalR • The project exists on GitHub but • NuGet is the best way to install it • Install Microsoft ASP.NET SignalR Tuesday, March 26, 13
  • 20. What’s in the Package? • SignalR Core - Server side stuff • SignalR JS - JavaScript library • SignalR Owin - An OWIN adapter • SignalR SystemWeb - To host on IIS Tuesday, March 26, 13
  • 21. Other Packages • SignalR Client - .NET client • SignalR Sample - A fake stock ticker • LCSK - Live chat app • SignalR.EventStream - Monitor your site • ElmahR.Elmah - ELMAH • and lots more Tuesday, March 26, 13
  • 22. What is OWIN? • Open Web Interface for .NET • A specification for the communication between .NET Web Server and Web App • IIS isn’t the only .NET Web Server, there is HttpListener, server.dll, Kayak, and potentially others • SignalR depends on OWIN for hosting Tuesday, March 26, 13
  • 23. What’s It Good For? • dashboards • monitoring • collaborative anything • job progress • real-time forms • gaming... Tuesday, March 26, 13
  • 26. Building DIRTy Apps • Data Intensive Real-Time(y) Apps • Two main classes: • PersistentConnections • Hubs Tuesday, March 26, 13
  • 27. Connections • The raw connection in SignalR • Can connect with 1 - n clients • Is an IHTTP handler • Requires route to be defined • Limited to sending message Tuesday, March 26, 13
  • 29. Hubs • Built on top of PersistentConnection • Can connect with 1 - n clients • Routes automatically mapped • Can send messages and call methods • SignalR defines the protocol Tuesday, March 26, 13
  • 31. Debugging • With Chrome • With Fiddler Tuesday, March 26, 13
  • 32. Clients • JavaScript (as a jQuery plugin) • .NET 4.0/4.5 • Silverlight 5 • Windows Store Apps • iOS (community) • MonoTouch (community) Tuesday, March 26, 13
  • 33. Clients • Windows Phone 8 • MonoTouch (official) • MonoDroid (official) • iOS (official) • .NET Micro Framework • Java Tuesday, March 26, 13
  • 34. Handling Success • Scale-out via the backplane • Azure ServiceBus • Redis • SQL Server Tuesday, March 26, 13
  • 35. Gotchas • Documentation is limited • Documentation may be out of date • But finally a released product! Tuesday, March 26, 13
  • 36. Resources • http://signalr.net/ • https://jabbr.net • https://github.com/SignalR/SignalR/wiki • http://www.asp.net/signalr/overview/getting- started/tutorial-getting-started-with-signalr Tuesday, March 26, 13
  • 37. Summary ASP.NET SignalR makes it incredibly easy to add real-time capabilities to your web app. Tuesday, March 26, 13