SlideShare une entreprise Scribd logo
1  sur  28
JANUARY 23, 2012 | SLIDE 1
www.realdolmen.com




                     USING SIGNALR FOR REALTIME CLIENT/SERVER
                                 COMMUNICATION




JANUARY 23, 2012 | SLIDE 2
WHO AM I?
        Maarten Balliauw
        Antwerp, Belgium
        www.realdolmen.com
        Focus on web
          ASP.NET MVC, PHP, Azure, SignalR, …
          MVP Windows Azure (formerly ASP.NET)
        Co-founder of AZUG
        http://blog.maartenballiauw.be
        @maartenballiauw




JANUARY 23, 2012 | SLIDE 4
AGENDA
        Why real-time & how?
        Meet SignalR
        Connections and Hubs
        Clients
        Q&A




JANUARY 23, 2012 | SLIDE 5
WHY REAL-TIME & HOW?


JANUARY 23, 2012 | SLIDE 6
USERS WANT THE LATEST INFORMATION, NOW!
        Twitter – live searches/updates
        Stock streamers
        Auctions
        Live scores
        New e-mail
        Real-time notifications
        Interactive games
        Collaborative apps
        Analytics of users
        …



JANUARY 23, 2012 | SLIDE 7
HTTP IS AN OLD BEAST…
        Never designed for real-time communications
          Web is request-response
          Web is stateless


        But…
          HTML5 WebSockets to the rescue,
           right?




JANUARY 23, 2012 | SLIDE 8
HTML5 WEBSOCKETS
        Extension to HTTP
        Provide raw sockets over HTTP
        Full-duplex
        Traverses proxies



        It’s still a draft…
        Not every proxy server supports it 
        Not every webserver supports it 
        Not every browser supports it 
        They are raw sockets!


JANUARY 23, 2012 | SLIDE 9
PERIODIC POLLING                                            Fiddler
                                                             hootsuite.com




        Bottom line:
          Poll from time to time using Ajax
          Delay in communications due to polling interval
          Wastes bandwidth & latency 


JANUARY 23, 2012 | SLIDE 10
LONG POLLING                                                      Fiddler
                                                                   facebook.com




        Bottom line:
          Poll but don’t respond untill there’s data
          Poll again after data received or after the connection times out
          Consumes server threads & connection resources 


JANUARY 23, 2012 | SLIDE 11
WHICH LEAVES US WITH 3 OPTIONS FOR REAL-TIME
        Periodic polling
        Long polling
        HTML5 WebSockets




JANUARY 23, 2012 | SLIDE 12
ARRR!
      MEET SIGNALR


JANUARY 23, 2012 | SLIDE 13
SIGNALR?
        Three-in-one!
          “Persistent” client/server connection over best transport
          Abstracts away the transport
          Provides just one programming model


        David Fowler and Damian Edwards
         (two guys on the ASP.NET team)
        Not an official Microsoft project (yet?)
        OSS project on Github, MIT licensed
         http://github.com/signalr/signalr
        Simple to setup & just works
        Depends on C# (not VB.NET), .NET 4+ and jQuery


JANUARY 23, 2012 | SLIDE 15
WHERE DO I GET IT?

                              *

          * where else!




JANUARY 23, 2012 | SLIDE 16
HELLO, SIGNALR!


JANUARY 23, 2012 | SLIDE 17
WHAT JUST HAPPENED?
        The server is broadcasting a message every few seconds
        Clients are receiving messages
        Code looks easy
        No polling or whatsoever (at least in my code)




JANUARY 23, 2012 | SLIDE 18
CONNECTIONS AND HUBS


JANUARY 23, 2012 | SLIDE 19
TWO CONNECTION MODELS

 PersistentConnection             Hubs
        Can communicate with        Can communicate with
         1..N clients                 1..N clients
        Is an IHttpHandler          Abstraction over
        Requires a route to be       PersistentConnection
         defined                     Route automatically
        Limited to sending           mapped (/signalr/hubs)
         messages                    Can send messages and
        You define the               call methods
         “protocol”                  SignalR defines the
                                      protocol



JANUARY 23, 2012 | SLIDE 20
HELLO, SIGNALR HUBS!


JANUARY 23, 2012 | SLIDE 21
HUBS
        Hub methods can be called from client
        Client methods can be called from hub
        Target individual client
        Target all clients
        Target group of clients
          http://jabbr.net




JANUARY 23, 2012 | SLIDE 22
CLIENTS


JANUARY 23, 2012 | SLIDE 23
SO FAR WE’VE USED…
        On the server side:
          Host in any ASP.NET application (SignalR.Server)


        On the client side:
          JavaScript (SignalR.JS)


        But there’s more…




JANUARY 23, 2012 | SLIDE 24
DECKCAST


JANUARY 23, 2012 | SLIDE 25
THAT’S A LOT MORE!
        On the server side:
          Host in any ASP.NET application (SignalR.Server)
          Use “SelfHost”
              https://github.com/SignalR/SignalR/tree/master/SignalR.SelfHost



        On the client side:
             JavaScript (SignalR.JS)
             Any .NET client (SignalR.Client)
             Any WP7 device (SignalR.Client.WP7)
             iOS
             Android


        Is this becoming a replacement for WCF?


JANUARY 23, 2012 | SLIDE 26
CONCLUSION
        SignalR is three-in-one!
          “Persistent” client/server connection over best transport
          Abstracts away the transport
          Provides just one programming model
        Connections & Hubs
        Connect various clients
        Make the web real-time!




JANUARY 23, 2012 | SLIDE 27
RESOURCES
        My blog:
         http://blog.maartenballiauw.be

        SignalR on Github:
         http://github.com/signalr/signalr
        SignalR on NuGet:
         http://www.nuget.org/packages?q=signalr

        Websockets:
         http://github.com/signalr/signalr.websockets
        Scale-out on Windows Azure:
         http://github.com/signalr/signalr.azure

        Objective C client:
         https://github.com/DyKnow/SignalR-ObjC
        Android client (using MonoDroid):
         https://github.com/SignalR/SignalR/pull/127

JANUARY 23, 2012 | SLIDE 28
Q&A


JANUARY 23, 2012 | SLIDE 29
THANK YOU FOR JOINING



JANUARY 23, 2012 | SLIDE 30

Contenu connexe

En vedette

En vedette (18)

Get satrted angular js
Get satrted angular jsGet satrted angular js
Get satrted angular js
 
Getting started with CSS frameworks using Zurb foundation
Getting started with CSS frameworks using Zurb foundationGetting started with CSS frameworks using Zurb foundation
Getting started with CSS frameworks using Zurb foundation
 
AngularJS in 60ish Minutes
AngularJS in 60ish MinutesAngularJS in 60ish Minutes
AngularJS in 60ish Minutes
 
Angular js
Angular jsAngular js
Angular js
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
Real time Communication
Real time CommunicationReal time Communication
Real time Communication
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
Fundamental JavaScript [UTC, March 2014]
Fundamental JavaScript [UTC, March 2014]Fundamental JavaScript [UTC, March 2014]
Fundamental JavaScript [UTC, March 2014]
 
Single Page Application (SPA) using AngularJS
Single Page Application (SPA) using AngularJSSingle Page Application (SPA) using AngularJS
Single Page Application (SPA) using AngularJS
 
AngularJS Basics with Example
AngularJS Basics with ExampleAngularJS Basics with Example
AngularJS Basics with Example
 
AngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedAngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get started
 
Reveal.js
Reveal.jsReveal.js
Reveal.js
 
Js ppt
Js pptJs ppt
Js ppt
 
Javascript
JavascriptJavascript
Javascript
 
JavaScript - An Introduction
JavaScript - An IntroductionJavaScript - An Introduction
JavaScript - An Introduction
 
Introduction to Angularjs
Introduction to AngularjsIntroduction to Angularjs
Introduction to Angularjs
 
reveal.js 3.0.0
reveal.js 3.0.0reveal.js 3.0.0
reveal.js 3.0.0
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript Programming
 

Plus de Maarten Balliauw

Plus de Maarten Balliauw (20)

Bringing nullability into existing code - dammit is not the answer.pptx
Bringing nullability into existing code - dammit is not the answer.pptxBringing nullability into existing code - dammit is not the answer.pptx
Bringing nullability into existing code - dammit is not the answer.pptx
 
Nerd sniping myself into a rabbit hole... Streaming online audio to a Sonos s...
Nerd sniping myself into a rabbit hole... Streaming online audio to a Sonos s...Nerd sniping myself into a rabbit hole... Streaming online audio to a Sonos s...
Nerd sniping myself into a rabbit hole... Streaming online audio to a Sonos s...
 
Building a friendly .NET SDK to connect to Space
Building a friendly .NET SDK to connect to SpaceBuilding a friendly .NET SDK to connect to Space
Building a friendly .NET SDK to connect to Space
 
Microservices for building an IDE - The innards of JetBrains Rider - NDC Oslo...
Microservices for building an IDE - The innards of JetBrains Rider - NDC Oslo...Microservices for building an IDE - The innards of JetBrains Rider - NDC Oslo...
Microservices for building an IDE - The innards of JetBrains Rider - NDC Oslo...
 
Indexing and searching NuGet.org with Azure Functions and Search - .NET fwday...
Indexing and searching NuGet.org with Azure Functions and Search - .NET fwday...Indexing and searching NuGet.org with Azure Functions and Search - .NET fwday...
Indexing and searching NuGet.org with Azure Functions and Search - .NET fwday...
 
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
NDC Sydney 2019 - Microservices for building an IDE – The innards of JetBrain...
 
JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...
JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...
JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...
 
.NET Conf 2019 - Indexing and searching NuGet.org with Azure Functions and Se...
.NET Conf 2019 - Indexing and searching NuGet.org with Azure Functions and Se....NET Conf 2019 - Indexing and searching NuGet.org with Azure Functions and Se...
.NET Conf 2019 - Indexing and searching NuGet.org with Azure Functions and Se...
 
CloudBurst 2019 - Indexing and searching NuGet.org with Azure Functions and S...
CloudBurst 2019 - Indexing and searching NuGet.org with Azure Functions and S...CloudBurst 2019 - Indexing and searching NuGet.org with Azure Functions and S...
CloudBurst 2019 - Indexing and searching NuGet.org with Azure Functions and S...
 
NDC Oslo 2019 - Indexing and searching NuGet.org with Azure Functions and Search
NDC Oslo 2019 - Indexing and searching NuGet.org with Azure Functions and SearchNDC Oslo 2019 - Indexing and searching NuGet.org with Azure Functions and Search
NDC Oslo 2019 - Indexing and searching NuGet.org with Azure Functions and Search
 
Approaches for application request throttling - Cloud Developer Days Poland
Approaches for application request throttling - Cloud Developer Days PolandApproaches for application request throttling - Cloud Developer Days Poland
Approaches for application request throttling - Cloud Developer Days Poland
 
Indexing and searching NuGet.org with Azure Functions and Search - Cloud Deve...
Indexing and searching NuGet.org with Azure Functions and Search - Cloud Deve...Indexing and searching NuGet.org with Azure Functions and Search - Cloud Deve...
Indexing and searching NuGet.org with Azure Functions and Search - Cloud Deve...
 
Approaches for application request throttling - dotNetCologne
Approaches for application request throttling - dotNetCologneApproaches for application request throttling - dotNetCologne
Approaches for application request throttling - dotNetCologne
 
CodeStock - Exploring .NET memory management - a trip down memory lane
CodeStock - Exploring .NET memory management - a trip down memory laneCodeStock - Exploring .NET memory management - a trip down memory lane
CodeStock - Exploring .NET memory management - a trip down memory lane
 
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
ConFoo Montreal - Microservices for building an IDE - The innards of JetBrain...
 
ConFoo Montreal - Approaches for application request throttling
ConFoo Montreal - Approaches for application request throttlingConFoo Montreal - Approaches for application request throttling
ConFoo Montreal - Approaches for application request throttling
 
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
Microservices for building an IDE – The innards of JetBrains Rider - TechDays...
 
JetBrains Day Seoul - Exploring .NET’s memory management – a trip down memory...
JetBrains Day Seoul - Exploring .NET’s memory management – a trip down memory...JetBrains Day Seoul - Exploring .NET’s memory management – a trip down memory...
JetBrains Day Seoul - Exploring .NET’s memory management – a trip down memory...
 
DotNetFest - Let’s refresh our memory! Memory management in .NET
DotNetFest - Let’s refresh our memory! Memory management in .NETDotNetFest - Let’s refresh our memory! Memory management in .NET
DotNetFest - Let’s refresh our memory! Memory management in .NET
 
VISUG - Approaches for application request throttling
VISUG - Approaches for application request throttlingVISUG - Approaches for application request throttling
VISUG - Approaches for application request throttling
 

Dernier

Dernier (20)

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 

SignalR - Code, not toothpaste - UGIALT.NET

  • 1. JANUARY 23, 2012 | SLIDE 1
  • 2. www.realdolmen.com USING SIGNALR FOR REALTIME CLIENT/SERVER COMMUNICATION JANUARY 23, 2012 | SLIDE 2
  • 3. WHO AM I?  Maarten Balliauw  Antwerp, Belgium  www.realdolmen.com  Focus on web  ASP.NET MVC, PHP, Azure, SignalR, …  MVP Windows Azure (formerly ASP.NET)  Co-founder of AZUG  http://blog.maartenballiauw.be  @maartenballiauw JANUARY 23, 2012 | SLIDE 4
  • 4. AGENDA  Why real-time & how?  Meet SignalR  Connections and Hubs  Clients  Q&A JANUARY 23, 2012 | SLIDE 5
  • 5. WHY REAL-TIME & HOW? JANUARY 23, 2012 | SLIDE 6
  • 6. USERS WANT THE LATEST INFORMATION, NOW!  Twitter – live searches/updates  Stock streamers  Auctions  Live scores  New e-mail  Real-time notifications  Interactive games  Collaborative apps  Analytics of users  … JANUARY 23, 2012 | SLIDE 7
  • 7. HTTP IS AN OLD BEAST…  Never designed for real-time communications  Web is request-response  Web is stateless  But…  HTML5 WebSockets to the rescue, right? JANUARY 23, 2012 | SLIDE 8
  • 8. HTML5 WEBSOCKETS  Extension to HTTP  Provide raw sockets over HTTP  Full-duplex  Traverses proxies  It’s still a draft…  Not every proxy server supports it   Not every webserver supports it   Not every browser supports it   They are raw sockets! JANUARY 23, 2012 | SLIDE 9
  • 9. PERIODIC POLLING Fiddler hootsuite.com  Bottom line:  Poll from time to time using Ajax  Delay in communications due to polling interval  Wastes bandwidth & latency  JANUARY 23, 2012 | SLIDE 10
  • 10. LONG POLLING Fiddler facebook.com  Bottom line:  Poll but don’t respond untill there’s data  Poll again after data received or after the connection times out  Consumes server threads & connection resources  JANUARY 23, 2012 | SLIDE 11
  • 11. WHICH LEAVES US WITH 3 OPTIONS FOR REAL-TIME  Periodic polling  Long polling  HTML5 WebSockets JANUARY 23, 2012 | SLIDE 12
  • 12. ARRR! MEET SIGNALR JANUARY 23, 2012 | SLIDE 13
  • 13. SIGNALR?  Three-in-one!  “Persistent” client/server connection over best transport  Abstracts away the transport  Provides just one programming model  David Fowler and Damian Edwards (two guys on the ASP.NET team)  Not an official Microsoft project (yet?)  OSS project on Github, MIT licensed http://github.com/signalr/signalr  Simple to setup & just works  Depends on C# (not VB.NET), .NET 4+ and jQuery JANUARY 23, 2012 | SLIDE 15
  • 14. WHERE DO I GET IT? * * where else! JANUARY 23, 2012 | SLIDE 16
  • 15. HELLO, SIGNALR! JANUARY 23, 2012 | SLIDE 17
  • 16. WHAT JUST HAPPENED?  The server is broadcasting a message every few seconds  Clients are receiving messages  Code looks easy  No polling or whatsoever (at least in my code) JANUARY 23, 2012 | SLIDE 18
  • 17. CONNECTIONS AND HUBS JANUARY 23, 2012 | SLIDE 19
  • 18. TWO CONNECTION MODELS PersistentConnection Hubs  Can communicate with  Can communicate with 1..N clients 1..N clients  Is an IHttpHandler  Abstraction over  Requires a route to be PersistentConnection defined  Route automatically  Limited to sending mapped (/signalr/hubs) messages  Can send messages and  You define the call methods “protocol”  SignalR defines the protocol JANUARY 23, 2012 | SLIDE 20
  • 19. HELLO, SIGNALR HUBS! JANUARY 23, 2012 | SLIDE 21
  • 20. HUBS  Hub methods can be called from client  Client methods can be called from hub  Target individual client  Target all clients  Target group of clients  http://jabbr.net JANUARY 23, 2012 | SLIDE 22
  • 22. SO FAR WE’VE USED…  On the server side:  Host in any ASP.NET application (SignalR.Server)  On the client side:  JavaScript (SignalR.JS)  But there’s more… JANUARY 23, 2012 | SLIDE 24
  • 24. THAT’S A LOT MORE!  On the server side:  Host in any ASP.NET application (SignalR.Server)  Use “SelfHost” https://github.com/SignalR/SignalR/tree/master/SignalR.SelfHost  On the client side:  JavaScript (SignalR.JS)  Any .NET client (SignalR.Client)  Any WP7 device (SignalR.Client.WP7)  iOS  Android  Is this becoming a replacement for WCF? JANUARY 23, 2012 | SLIDE 26
  • 25. CONCLUSION  SignalR is three-in-one!  “Persistent” client/server connection over best transport  Abstracts away the transport  Provides just one programming model  Connections & Hubs  Connect various clients  Make the web real-time! JANUARY 23, 2012 | SLIDE 27
  • 26. RESOURCES  My blog: http://blog.maartenballiauw.be  SignalR on Github: http://github.com/signalr/signalr  SignalR on NuGet: http://www.nuget.org/packages?q=signalr  Websockets: http://github.com/signalr/signalr.websockets  Scale-out on Windows Azure: http://github.com/signalr/signalr.azure  Objective C client: https://github.com/DyKnow/SignalR-ObjC  Android client (using MonoDroid): https://github.com/SignalR/SignalR/pull/127 JANUARY 23, 2012 | SLIDE 28
  • 27. Q&A JANUARY 23, 2012 | SLIDE 29
  • 28. THANK YOU FOR JOINING JANUARY 23, 2012 | SLIDE 30

Notes de l'éditeur

  1. How do youimplement these today?
  2. That’s a lot of options, a lot of thingsto account forand a lot of different programmingmodels. Are yougoingto do this?Are youstillwriting separategetDocumentByIdandAttachEventmethodstoworkwith the DOM? WhataboutjQuery?
  3. Open VS2010Create a new ASP.NET Empty WebsiteInstall-PackageSignalRNote server library, client script, jQuery dependencyInstall-Package SignalR.Sample and show stock ticker in two browsersNowlet’s take things easy… How does all of thiswork?----------------- without Internet connection ----------------------------Add a class:public class TimeConnection : PersistentConnection{}Add a route:RouteTable.Routes.MapConnection<TimeConnection>("time", "time/{*operation}"); Addaninfinite loop:ThreadPool.QueueUserWorkItem(_ => { var connection = Connection.GetConnection<TimeConnection>();while (true) {connection.Broadcast(DateTime.Now.ToString());Thread.Sleep(1000); } });Addsome HTML:<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head> <title></title> <script src="Scripts/jquery-1.6.4.min.js" type="text/javascript"></script> <script src="Scripts/jquery.signalR.js" type="text/javascript"></script> <script type="text/javascript"> $(function () { var connection = $.connection('time');connection.received(function(data) { $('h1').text('The time is ' + data); });connection.start(); }); </script></head><body> <h1>The time is now!</h1></body></html>----------------- without Internet connection --------------------------------------------- with Internet connection ----------------------------Install-Package LinqToTwitterAdd a class:public class TweetsConnection : PersistentConnection{}Add a route:RouteTable.Routes.MapConnection<TweetsConnection>("tweets", "tweets/{*operation}"); Addaninfinite loop:ThreadPool.QueueUserWorkItem(_ => { var connection = Connection.GetConnection<TweetsConnection>();while (true) {using (TwitterContext context = new TwitterContext()) { var tweets = context.Search.Where(t => t.Type == SearchType.Search && t.Query == "#test").SingleOrDefault().Entries;connection.Broadcast(tweets.ToList()); }Thread.Sleep(5000); } });Addsome HTML:<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head> <title></title> <script src="Scripts/jquery-1.6.4.min.js" type="text/javascript"></script> <script src="Scripts/jquery.signalR.js" type="text/javascript"></script> <script type="text/javascript"> $(function () { var connection = $.connection('tweets');connection.received(function (data) { $('#tweetsList').html('');for (var i = 0; i < data.length; i++) { $('#tweetsList').append($('<li>' + data[i].Content + '</li>')); } });connection.start(); }); </script></head><body> <h1>Tweets</h1> <ulid="tweetsList"></ul></body></html>----------------- with Internet connection ----------------------------Notice we are sending data TO the client?
  4. Open the previouslycreated sampleInstall-Package jQuery.UI.CombinedAdd a class: [HubName("worker")] public class WorkerHub : Hub { public voidstartProcessing(Event e) {Caller.notify("We'vestarted processing " + e.EventName);Clients.setProgress(10);for (int i = 0; i <= 100; i++) {SignalR.Hubs.Hub.GetClients<WorkerHub>().setProgress(i);Thread.Sleep(100); } } }Addsome HTML:<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head> <title></title> <link rel="stylesheet" href="Content/themes/base/jquery.ui.all.css" /> <script src="Scripts/jquery-1.6.4.min.js" type="text/javascript"></script> <script src="Scripts/jquery-ui-1.8.16.min.js" type="text/javascript"></script> <script src="Scripts/jquery.signalR.js" type="text/javascript"></script> <script src="signalr/hubs" type="text/javascript"></script> <script type="text/javascript"> $(function () { var workerHub = $.connection.worker; $('#progressbar').progressbar({ value: 0 }); $('#startWorkTrigger').bind('click', function () {workerHub.startProcessing({ eventName: 'UAN12' }) .fail(function (e) { alert("An error occured: " + e); }); });workerHub.notify = function (message) { $('#notifications').html(message); };workerHub.setProgress = function (progress) { $('#progressbar').progressbar({ value: progress }); }; $.connection.hub.start(); }); </script></head><body> <div id="progressbar" style="width: 200px;"></div> <div id="notifications" style="width: 200px;"></div> <button id="startWorkTrigger">Start work</button></body></html>
  5. Open DeckCastShow peoplearoundandtellthemabout deck.jsShow the presenter mode andclient mode on the webStart a console based viewerStart the WP7 presenter app (focus/unfocus the “sample” box toconnect, click SLOWLY)