signalr with asp.net part1

32
SignalR By Esraa Ammar

Upload: esraa-ammar

Post on 13-Aug-2015

78 views

Category:

Software


1 download

TRANSCRIPT

Page 1: SignalR With ASP.Net part1

SignalR

B y E s r a a A m m a r

Page 2: SignalR With ASP.Net part1

Topics Focused On!!!• Traditional Web Approach

– Traditional Web Approach – Issues

• What does “Real Time” mean?

• SignalR– Types of Transports– Types of Connections

• How do I get SignalR?

• Demo

Page 3: SignalR With ASP.Net part1

Traditional Web Approach“Pulling”

Page 4: SignalR With ASP.Net part1

CLIENT

SERVER

Traditional Web ApproachSends a Request to the Server – (Step 1)[In other words, the Client is trying to

pull some information from the Server]

Processes the Request

(Step 2)

Response Sent back to the Client – (Step 3)

Page 5: SignalR With ASP.Net part1

• Not Persistent connection – IssuesEach time re-established for each communication.

• Http Request – Issues

Page 6: SignalR With ASP.Net part1

Real Time Web Applications

Page 7: SignalR With ASP.Net part1

What is Real Time Web Application?

• “Real Time” means an immediate response being sent by the Server to the Client.

• Real Time is “Pushing” instead of “Pulling”

• Push Technology is completely different from Pull Technology. Its about getting told what’s new, instead of asking for what’s new!!!

Page 8: SignalR With ASP.Net part1

CLIENT

SERVER

User Sends a Request to the Server

Creates a Persistent Connection between them

Real Time Web Approach

Response Sent back to the Client

Response Sent back to the Client

Response Sent back to the Client

Page 9: SignalR With ASP.Net part1

Comet Transports

Page 10: SignalR With ASP.Net part1

Long Polling

Server

Client

Requ

est

Resp

onse

Variable delay

• Long polling does not create a persistent connection, but instead polls the server with a request that stays open until the server responds, at which point the connection closes, and a new connection is requested immediately.

Page 11: SignalR With ASP.Net part1

Forever Frames• Internally creates an Iframe along with a

script on the page to fetch the data.

• The server then continually sends script to the client which is immediately executed, providing a one-way realtime connection from server to client.

• Supported on IE Browser.

Page 12: SignalR With ASP.Net part1

HTML5 Transports

Page 13: SignalR With ASP.Net part1

Server Sent Events

Page 14: SignalR With ASP.Net part1

Server Sent Events• Requires a single connection between Client-Server.

• Works in server-to-client direction only

• Used to send Message Notifications or Continuous Data Streams.

• Support a lot of Browsers but Not supported in IE.

Page 15: SignalR With ASP.Net part1

WebSocket

Page 16: SignalR With ASP.Net part1

WebSocket• A new HTML5 API that enables bi-directional, full duplex

communication between the browser and server.

• Fastest solution

• Issues– Supported only on latest browsers – Works only with IIS-8.0

Page 17: SignalR With ASP.Net part1

SignalR• SignalR is a library for ASP.NET developers. Used to

develop Real Time Web Application.

• Makes use of Push Technology.

• Provides Abstraction over the set of transports.

• Open Source available on Github!!!

Page 18: SignalR With ASP.Net part1

SignalR

Transport Techniques

Connections

Page 19: SignalR With ASP.Net part1

Transport Priority

WebSockets

Server-Sent events

Forever Frame (IE hack)

Long Polling

HTML 5 transports

Comet transports

Page 20: SignalR With ASP.Net part1

SignalR Connections

Hubs

Persistent Connection

Page 21: SignalR With ASP.Net part1

Persistent Connection

• low-level control to manage connection.

• Contain events like “OnConnection”, “OnDisconnection”, “OnReconnection”

• We can write our own logic in these events.

Page 22: SignalR With ASP.Net part1

Hubs

Page 23: SignalR With ASP.Net part1

Hubs

• Provides a High-level API.

• Client calling Server.

• Server calling Clients. (All, Groups, One).

• Broadcasting messages to all connected clients.

Page 24: SignalR With ASP.Net part1

Connection lifetime

Page 25: SignalR With ASP.Net part1

Connection lifetime

Page 26: SignalR With ASP.Net part1

How do I get SignalR?

Page 27: SignalR With ASP.Net part1

Install-Package Microsoft.AspNet.SignalR

Page 28: SignalR With ASP.Net part1

Some References

Page 29: SignalR With ASP.Net part1

Routing is Very Important

Page 30: SignalR With ASP.Net part1

Server Calling Client

Page 31: SignalR With ASP.Net part1

Client Calling Server Function

Page 32: SignalR With ASP.Net part1

DEMO