Presentation on theme: "IoT with SignalR & .NET Gadgeteer"— Presentation transcript:
1IoT with SignalR & .NET Gadgeteer Internet of Things & .NET Gadgeteer & Microsoft SignalR Mirco VaniniMicrosoft® MVP Windows Embedded
2AgendaPerché real-time e come ? SignalR Connections and Hubs Clients Demo Q&A Links
3Perché real-time e come ? Gli utenti vogliono le ultime informazioni, ORA !Twitter – live searches/updatesStock streamersAuctionsLive scoresReal-time notificationsInteractive gamesCollaborative appsLive user analytics
4Perché real-time e come ? HTTP is an old beast…Never designed for real-time communicationsWeb is request-responseWeb is statelessHTML5 WebSockets to the rescue, right?Extension to HTTPProvide raw sockets over HTTPFull-duplexTraverses proxiesIt’s still a draft…Not every proxy server supports itNot every webserver supports itNot every browser supports itThey are raw sockets!
5Perché real-time e come ? Come implementare il real-time con HTTP: Polling. Long Polling. Forever Frame. Server Sent Events
6Perché real-time e come ? Polling: the stubborn approachServerResponseRequestClientdelayTime: requests event ‘n’ seconds (fixed time)Twitter clients
7Perché real-time e come ? PollingHigh overhead on requests: headers and such…High overhead on response: same as before…High latency.Waste of bandwith.Waste of resources.
8Perché real-time e come ? Long Polling: the kind gentleman approachServerResponseRequestClientVariable delayTime: requests event ‘n’ seconds (variable)Facebook chat
9Perché real-time e come ? Long Polling (Hanging GET)High overhead on requests: headers and such…High overhead on response: same as before…Medium latency.Waste less of bandwith.Waste of resources.Better than the previous one: less requests
10Perché real-time e come ? Forever FrameServerHTTP/ OK Content-Type: text/plain Transfer-Encoding: chunkedServer tells client that response is chunckedClient keeps connection open untill server closes itServer pushes data to the client followed by \0Consumes server threads<script>eval("... ")</script>\0<script>eval("... ")</script>\0Client
\0. \0. Client.",
12Real-time: How to survive ? So many options and a big Headache !
14Try WebSocket then fallback to: SignalRWorks everywhere !!!Try WebSocket then fallback to:Server Sent EventsForever FrameLong PollingBet to keep the logic connection up include retry logicScale out to web-farms
15SignalRComplete rewrite of the internals for 1.0.0Very hight performance on a single box ’s of messages per secondsVery low memory overheadFull async1000’s of connection per serverCross-platform: run it on OSX or Linux with MonoSupported part of ASP.NET family
18SignalR packages Core Meta package Hosts Microsoft.AspNet.SignalR.Core: Server side components needed to build SignalR endpointsMeta packageMicrosoft.AspNet.SignalR: - A meta package that brings in everything you need to run it on IIS and ASP.NETHostsMicrosoft.AspNet.SignalR.SystemWeb - Pulls in the required packages to host SignalR in ASP.NET (via OWIN ASP.NET host)Microsoft.AspNet.SignalR.Owin - OWIN* host for SignalR* OWIN stands for “Open Web Interface for .NET” and it is a specification for the communication between .NET Web Server and Web applications.