Presentation on theme: "Internet of Things &.NET Gadgeteer & Microsoft SignalR Mirco Vanini IoT with SignalR &.NET Gadgeteer Microsoft® MVP Windows Embedded."— Presentation transcript:
Internet of Things &.NET Gadgeteer & Microsoft SignalR Mirco Vanini IoT with SignalR &.NET Gadgeteer Microsoft® MVP Windows Embedded
Agenda Perché real-time e come ? SignalR Connections and Hubs Clients Demo Q&A Links
Perché real-time e come ? Gli utenti vogliono le ultime informazioni, ORA ! Twitter – live searches/updates Stock streamers Auctions Live scores Real-time notifications Interactive games Collaborative apps Live user analytics
Perché real-time e come ? HTTP is an old beast… Never designed for real-time communications Web is request-response Web is stateless HTML5 WebSockets to the rescue, right?WebSockets Extension to HTTP Provide raw sockets over HTTP Full-duplex Traverses proxies Its still a draft… Not every proxy server supports it Not every webserver supports it Not every browser supports it They are raw sockets!
Perché real-time e come ? Come implementare il real-time con HTTP: Polling. Long Polling. Forever Frame. Server Sent Events
Perché real-time e come ? Polling: the stubborn approach Server Client Time: requests event n seconds (fixed time) Request Response delay Twitter clients
Perché real-time e come ? Polling High overhead on requests: headers and such… High overhead on response: same as before… High latency. Waste of bandwith. Waste of resources.
Perché real-time e come ? Long Polling: the kind gentleman approach Server Client Time: requests event n seconds (variable) Request Response Variable delay Facebook chat
Perché 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
Perché real-time e come ? HTTP/ OK Content-Type: text/plain Transfer-Encoding: chunked Server tells client that response is chuncked Client keeps connection open untill server closes it Server pushes data to the client followed by \0 Consumes server threads eval("... ") \0 Forever Frame
Real-time: How to survive ? So many options and a big Headache !
SignalR Works everywhere !!! Try WebSocket then fallback to: Server Sent Events Forever Frame Long Polling Bet to keep the logic connection up include retry logic Scale out to web-farms
SignalR Complete rewrite of the internals for Very hight performance on a single box s of messages per seconds Very low memory overhead Full async 1000s of connection per server Cross-platform: run it on OSX or Linux with Mono Supported part of ASP.NET family
SignalR packages Core Microsoft.AspNet.SignalR.Core: Server side components needed to build SignalR endpoints Meta package Microsoft.AspNet.SignalR: - A meta package that brings in everything you need to run it on IIS and ASP.NET Hosts Microsoft.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* OWIN stands for Open Web Interface for.NET and it is a specification for the communication between.NET Web Server and Web applications.