signalr with asp.net part1
TRANSCRIPT
![Page 1: SignalR With ASP.Net part1](https://reader038.vdocuments.mx/reader038/viewer/2022103119/55ccad82bb61eb0b3f8b45c3/html5/thumbnails/1.jpg)
SignalR
B y E s r a a A m m a r
![Page 2: SignalR With ASP.Net part1](https://reader038.vdocuments.mx/reader038/viewer/2022103119/55ccad82bb61eb0b3f8b45c3/html5/thumbnails/2.jpg)
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](https://reader038.vdocuments.mx/reader038/viewer/2022103119/55ccad82bb61eb0b3f8b45c3/html5/thumbnails/3.jpg)
Traditional Web Approach“Pulling”
![Page 4: SignalR With ASP.Net part1](https://reader038.vdocuments.mx/reader038/viewer/2022103119/55ccad82bb61eb0b3f8b45c3/html5/thumbnails/4.jpg)
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](https://reader038.vdocuments.mx/reader038/viewer/2022103119/55ccad82bb61eb0b3f8b45c3/html5/thumbnails/5.jpg)
• Not Persistent connection – IssuesEach time re-established for each communication.
• Http Request – Issues
![Page 6: SignalR With ASP.Net part1](https://reader038.vdocuments.mx/reader038/viewer/2022103119/55ccad82bb61eb0b3f8b45c3/html5/thumbnails/6.jpg)
Real Time Web Applications
![Page 7: SignalR With ASP.Net part1](https://reader038.vdocuments.mx/reader038/viewer/2022103119/55ccad82bb61eb0b3f8b45c3/html5/thumbnails/7.jpg)
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](https://reader038.vdocuments.mx/reader038/viewer/2022103119/55ccad82bb61eb0b3f8b45c3/html5/thumbnails/8.jpg)
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](https://reader038.vdocuments.mx/reader038/viewer/2022103119/55ccad82bb61eb0b3f8b45c3/html5/thumbnails/9.jpg)
Comet Transports
![Page 10: SignalR With ASP.Net part1](https://reader038.vdocuments.mx/reader038/viewer/2022103119/55ccad82bb61eb0b3f8b45c3/html5/thumbnails/10.jpg)
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](https://reader038.vdocuments.mx/reader038/viewer/2022103119/55ccad82bb61eb0b3f8b45c3/html5/thumbnails/11.jpg)
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](https://reader038.vdocuments.mx/reader038/viewer/2022103119/55ccad82bb61eb0b3f8b45c3/html5/thumbnails/12.jpg)
HTML5 Transports
![Page 13: SignalR With ASP.Net part1](https://reader038.vdocuments.mx/reader038/viewer/2022103119/55ccad82bb61eb0b3f8b45c3/html5/thumbnails/13.jpg)
Server Sent Events
![Page 14: SignalR With ASP.Net part1](https://reader038.vdocuments.mx/reader038/viewer/2022103119/55ccad82bb61eb0b3f8b45c3/html5/thumbnails/14.jpg)
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](https://reader038.vdocuments.mx/reader038/viewer/2022103119/55ccad82bb61eb0b3f8b45c3/html5/thumbnails/15.jpg)
WebSocket
![Page 16: SignalR With ASP.Net part1](https://reader038.vdocuments.mx/reader038/viewer/2022103119/55ccad82bb61eb0b3f8b45c3/html5/thumbnails/16.jpg)
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](https://reader038.vdocuments.mx/reader038/viewer/2022103119/55ccad82bb61eb0b3f8b45c3/html5/thumbnails/17.jpg)
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](https://reader038.vdocuments.mx/reader038/viewer/2022103119/55ccad82bb61eb0b3f8b45c3/html5/thumbnails/18.jpg)
SignalR
Transport Techniques
Connections
![Page 19: SignalR With ASP.Net part1](https://reader038.vdocuments.mx/reader038/viewer/2022103119/55ccad82bb61eb0b3f8b45c3/html5/thumbnails/19.jpg)
Transport Priority
WebSockets
Server-Sent events
Forever Frame (IE hack)
Long Polling
HTML 5 transports
Comet transports
![Page 20: SignalR With ASP.Net part1](https://reader038.vdocuments.mx/reader038/viewer/2022103119/55ccad82bb61eb0b3f8b45c3/html5/thumbnails/20.jpg)
SignalR Connections
Hubs
Persistent Connection
![Page 21: SignalR With ASP.Net part1](https://reader038.vdocuments.mx/reader038/viewer/2022103119/55ccad82bb61eb0b3f8b45c3/html5/thumbnails/21.jpg)
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](https://reader038.vdocuments.mx/reader038/viewer/2022103119/55ccad82bb61eb0b3f8b45c3/html5/thumbnails/22.jpg)
Hubs
![Page 23: SignalR With ASP.Net part1](https://reader038.vdocuments.mx/reader038/viewer/2022103119/55ccad82bb61eb0b3f8b45c3/html5/thumbnails/23.jpg)
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](https://reader038.vdocuments.mx/reader038/viewer/2022103119/55ccad82bb61eb0b3f8b45c3/html5/thumbnails/24.jpg)
Connection lifetime
![Page 25: SignalR With ASP.Net part1](https://reader038.vdocuments.mx/reader038/viewer/2022103119/55ccad82bb61eb0b3f8b45c3/html5/thumbnails/25.jpg)
Connection lifetime
![Page 26: SignalR With ASP.Net part1](https://reader038.vdocuments.mx/reader038/viewer/2022103119/55ccad82bb61eb0b3f8b45c3/html5/thumbnails/26.jpg)
How do I get SignalR?
![Page 27: SignalR With ASP.Net part1](https://reader038.vdocuments.mx/reader038/viewer/2022103119/55ccad82bb61eb0b3f8b45c3/html5/thumbnails/27.jpg)
Install-Package Microsoft.AspNet.SignalR
![Page 28: SignalR With ASP.Net part1](https://reader038.vdocuments.mx/reader038/viewer/2022103119/55ccad82bb61eb0b3f8b45c3/html5/thumbnails/28.jpg)
Some References
![Page 29: SignalR With ASP.Net part1](https://reader038.vdocuments.mx/reader038/viewer/2022103119/55ccad82bb61eb0b3f8b45c3/html5/thumbnails/29.jpg)
Routing is Very Important
![Page 30: SignalR With ASP.Net part1](https://reader038.vdocuments.mx/reader038/viewer/2022103119/55ccad82bb61eb0b3f8b45c3/html5/thumbnails/30.jpg)
Server Calling Client
![Page 31: SignalR With ASP.Net part1](https://reader038.vdocuments.mx/reader038/viewer/2022103119/55ccad82bb61eb0b3f8b45c3/html5/thumbnails/31.jpg)
Client Calling Server Function
![Page 32: SignalR With ASP.Net part1](https://reader038.vdocuments.mx/reader038/viewer/2022103119/55ccad82bb61eb0b3f8b45c3/html5/thumbnails/32.jpg)
DEMO