Signal R 2015
-
Upload
mihai-coscodan -
Category
Technology
-
view
92 -
download
1
Transcript of Signal R 2015
SUMMARY• DEFINING PROBLEM SPACE
• EXISTING TECHNOLOGIES
• INTRODUCTION TO SIGNALR
• ARCHITECTURE AND COMPONENTS
• DEMO/EXAMPLES
THE PROBLEM: CLIENT WANT FRESH DATA• You (the «customer») want latest info (data)!
• You need them NOW!
• Real Time!
Examples of apps :
• Twitter / Facebook / many more…
• Notifications.
• Auctions / Stock trading / Banking.
• Live user analitics
• Search/update
• Collaborative apps(Google docs,
• Interactive games
REAL TIME APPLICATIONS, DEVELOPER VIEW
• Persistent Connections between endpoints.
• Two way communication (full-duplex).
• Low Latency ( :D ).
• Low overhead.
• Over the «wire» (intranet/internet/generic communication medium).
EXISTING TECHNIQUES/SOLUTIONS
• Pooling;
• Long Pooling;
• Forever Frame;
• Server Sent Events(SSE);
• WebSockets;
PERIODIC POLLING
Poll from time to time using Ajax Delay in communication due to polling interval Wastes bandwidth & latency & resources
Server
ClientPolling interval
LONG POLLING
Poll but doesn’t respond until there's data Poll again after data received or after the connection times out Consumes server & threads & connection resources Better than the previous one: less requests.
Server
Client
FOREVER FRAME
Server
Client
This technique is very low-latency because it avoids HTTP and TCP/IP set-up and tear-down by reusing a single long-lived connection. It uses "chunked encoding", a feature of HTTP/1.1 intended for an entirely different purpose, but which allows the server to maintain a connection to the client indefinitely, sending additional data to the client at will.
IFRAME ("Forever frame"): Loading a page in an IFRAME that incrementally receives commands wrapped in <script> tags, which the browser evaluates as they are received.
• Data is sent out in chunks.• Add an IFrame to the page (its content length is declared to be
indefinitely long).• Load in the IFrame a page with a script in it (execute it to get your
chunk of data).• The next chunk of data arrives in the form of another script that is
executed again.• The cycle goes on and on and on...
It causes pollution in the long run…all those script tags stays there even if you don’t need them anymore.
FOREVER FRAME IE WAY
Server-Sent Events (SSE) are a standard describing how servers can initiate data transmission towards clients once an initial client connection has been established. They are commonly used to send message updates or continuous data streams to a browser client and designed to enhance native, cross-browser streaming through a JavaScript API called EventSource, through which a client requests a particular URL in order to receive an event stream.
Server-Sent Events (SSE)
HOW TO BUILD REAL-TIME WEB APPS?
Never designed for real-time communications
Web is all about request-response
Web is stateless
INTRODUCTING SIGNALR HISTORY
• Signal R was created as an open source project by two Microsoft employees: David Fowler & Damien Edwards
• Adopted by Microsoft, but remains open source on GitHub
• Like jQuery for communication
• Distributed via NuGet
INTRODUCTING SIGNALR
• SignalR is a series of abstractions around a few persistent HTTP techniques(library).
• Persistent Connection Abstraction communication library.
• Abstracts protocol and transfer (choses the best one).
• A single programming model (a unified development experience).
• Extremely simple to use.
• Server-side it can be hosted in different «environments» (ASP.NET, console apps, windows services, etc…).
• Client-side there’s support for: Javascript clients, .NET clients, WP; provide by the community: iOS, Android.
SIGNALR COMPONENTS
Clients.NET 4.0+
JavaScript
Windows store apps
Silverlight 5
Windows Phone 8
iOS
Android
Hosts
ASP.NET
OWIN
Backplanes
SQL
Service Bus
Redis
TWO LEVELS OF ABSTRACTION
Picture was taken from book ASP.NET SignalR Incredibily simple real-time features for your web apps by Jose M. Aguilar
CONCEPTUAL IMPLEMENTATION OF HUBS
The use of hubs is recommended when we need to send different types ofmessages with various structures between the client and the server.
CONCLUSIONS
• SignalR is a server-side software system designed for writing scalable Internet applications, notably web servers. Programs are written on the server side in C#, using event-driven, asynchronous I/O to minimize overhead and maximize scalability.
• SignalR takes advantage of several transports, automatically selecting the best available transport given the client's and server's best available transport.
RESOURCES
Microsoft ASP.NET SignalR: The Real-Time Web Made Simplehttp://channel9.msdn.com/Events/TechEd/NorthAmerica/2013/DEV-B302
Building Real-time Web Apps with ASP.NET SignalRhttp://channel9.msdn.com/Events/Build/2012/3-034
Introducing ASP.NET SignalR - Push Services with Hubshttp://pluralsight.com/training/courses/TableOfContents?courseName=signalr-
introductiongithub.com/SignalR/SignalRhttps://html.spec.whatwg.org/multipage/comms.html