Realtime web experience with signalR

1,804 views

Published on

Realtime web experience with signalR presentation at the Israeli Web Developers group - WDCIL

  • Be the first to comment

  • Be the first to like this

Realtime web experience with signalR

  1. 1. © Copyright SELA software & Education Labs Ltd. 14-18 Baruch Hirsch St.Bnei Brak 51202 Israel www.sela.co.il
  2. 2. What is “Real Time”experience“Real Time” web techniquesWhat is signalRSignalR protocolConnection & HubGroups and privatemessages.Net clientSelf HostingScaleout
  3. 3. WebSocket ServerSentEvents ForeverFrames Long-PollingPolling
  4. 4. • Not all servers support web sockets• Not all network components support web sockets• It’s API is limited
  5. 5. • Code once, deploy everywhere• As cross-platform as possible• Simple API to work with
  6. 6. • Open source project• Abstraction layer over connection technique• Can be self-hosted• Call client methods from the server WebSocket ServerSentEvents = ForeverFrames Long-Polling Polling
  7. 7. WebSocket SignalR• Good performance • Abstraction layer• Strict prerequisites • Reach API• Limited API • Supports WebSocket
  8. 8. Negotiate request ServerClient Negotiate response Connection phase
  9. 9. • WebSocket-like API• Lower level code• Provides us with more control
  10. 10. • Abstraction over signalR connection• Service-like API• Call clients methods from the server
  11. 11. • You can use connection ID• You can access a particular client by itClients.Client(connectionId).sendMessage(message)
  12. 12. • Part of Hub API• Stored on client• Not persistent
  13. 13. _connection = new HubConnection("http://localhost/RanWahle.Blog.SignalR.Demo");IHubProxy proxy = connection.CreateHubProxy("soccerResultsHub");_connection.Start().ContinueWith( //define proxies); //invoke server methods _proxy.Invoke(“HubServerMethod“ , args…));
  14. 14. • Three NuGet packages to install• Create class with Configuration method.• Map hub in the Configuration method• Use the class as a type parameter to WebApplication.Start
  15. 15. • signalR supports ASP.NET authentication & authorization• AuthorizeAttribute• Accessing user data from context• Authenticated request may downdgrade to serverSentEvents in some clients.
  16. 16. • Install Redis for Linux or Clone the windows porting• Add One line of code• On Windows – run redis from command line• Your app is ready to scaleout
  17. 17. Real time experience is more thanjust pollingUsing signalR can use the bestavailable techniqueIt can be self hostedIt can scale outIt has several clients
  18. 18. • http://www.asp.net/signalr• http://signalr.net/• Twitters:@signalr @DamianEdwards @davidfowl and @DavianFowlwards• http://blogs.Microsoft.co.il/blogs/ranw
  19. 19. © Copyright SELA software & Education Labs Ltd. 14-18 Baruch Hirsch St.Bnei Brak 51202 Israel www.sela.co.il

×