Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
SignalR
Realtime client/server
communication
Maarten Balliauw
@maartenballiauw
R
Who am I?
Maarten Balliauw
Antwerp, Belgium
Developer Advocate, JetBrains
Founder, MyGet
AZUG
Focus on web
ASP.NET MVC, Az...
Agenda
Why real-time & how?
Meet SignalR
Connections and Hubs
Clients
.NET Core
Q&A
Why real-time & how?
Users want the latest info, now!
Twitter – live searches/updates
Stock tickers
Auctions
Live scores
Real-time notification...
HTTP is and old beast
Never designed for real-time communications
Web is request-response
Web is stateless
Websockets to t...
Websockets
Extension to HTTP
Provide raw sockets over HTTP
Full-duplex, low latency
Traverses proxies
But…
Not every proxy...
Forever Frame
Server tells client that response is chuncked
Client keeps connection open untill server closes it
Server pu...
Periodic polling
Poll from time to time using Ajax
Delay in communications due to polling interval
Wastes bandwidth & late...
Long polling
Poll but don’t respond until there’s data
Poll again after data received or after the connection times out
Co...
Options!
Forever Frame
Periodic polling
Long polling
Websockets
(Server-Sent events)
SignalR
SignalR
Three-in-one!
“Persistent” client/server connection over best transport
Connection negotiation
Abstracts away the ...
Hello, SignalR
DEMO
What just happened?
The server is broadcasting a message every few seconds
Clients are receiving messages
Code looks easy
...
Connections and Hubs
Two programming models
PERSISTENT CONNECTION
Can communicate with 1..N clients
Requires a route to be defined
Limited to s...
Hello, Hubs
DEMO
Hubs
Hub methods can be called from client
Client methods can be called from hub
Target individual client
Target all clien...
Clients
So far we have used...
On the server side
Host in any ASP.NET application (SignalR.Server)
On the client side
JavaScript (...
Connecting to
SignalR
DEMO
There is more!
On the server side
Host in any ASP.NET application (SignalR.Server) or using self-hosting (OWIN based)
Host...
DeckCast
DEMO
.NET Core
ASP.NET Core Sockets
SignalR in the ASP.NET Core world
Improvements based on SignalR learnings:
No more jQuery
No more ifr...
ASP.NET Core Sockets
New features:
Cross-platform (including things like RaspberryPi)
Binary data support (think sending i...
Demo?
Will leave this one for you...
Under development! https://github.com/aspnet/signalr
Preview release mid-year
Release...
Conclusion
Conclusion
SignalR is three-in-one!
“Persistent” client/server connection over best transport
Abstracts away the transport...
Thank you!
http://blog.maartenballiauw.be
@maartenballiauw
You’ve finished this document.
Download and read it offline.
Upcoming SlideShare
What to Upload to SlideShare
Next
Upcoming SlideShare
What to Upload to SlideShare
Next
Download to read offline and view in fullscreen.

0

Share

SignalR - Realtime client/server communication (iSense)

Download to read offline

Today’s users are interested in a rich experience where the terms client and server don’t mean a thing. They expect real-time action between both, no matter if the technology used is HTML5 websockets or something else. This session will cover SignalR and show you how it can be used to communicate in real time between the client and server, using HTML5 or not. Combine SignalR with ASP.NET MVC, JavaScript and perhaps a sprinkle of Azure and you’ll have an interesting, reliable and fast stack to build your real-time client-server and server-client communications. Join me on this journey between web, cloud and user. No toothpaste. Just code.

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all
  • Be the first to like this

SignalR - Realtime client/server communication (iSense)

  1. 1. SignalR Realtime client/server communication Maarten Balliauw @maartenballiauw
  2. 2. R
  3. 3. Who am I? Maarten Balliauw Antwerp, Belgium Developer Advocate, JetBrains Founder, MyGet AZUG Focus on web ASP.NET MVC, Azure, SignalR, ... Former MVP Azure & ASPInsider Big passion: Azure http://blog.maartenballiauw.be @maartenballiauw
  4. 4. Agenda Why real-time & how? Meet SignalR Connections and Hubs Clients .NET Core Q&A
  5. 5. Why real-time & how?
  6. 6. Users want the latest info, now! Twitter – live searches/updates Stock tickers Auctions Live scores Real-time notifications Collaborative apps Live user analytics Online gaming / browser games … 6
  7. 7. HTTP is and old beast Never designed for real-time communications Web is request-response Web is stateless Websockets to the rescue!
  8. 8. Websockets Extension to HTTP Provide raw sockets over HTTP Full-duplex, low latency Traverses proxies But… Not every proxy server supports it Not every webserver supports it Not every browser supports it Some antivirus blocks it They are raw sockets! (protocol: up to you) http://websocketstest.com/
  9. 9. Forever Frame 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 HTTP/1.1 200 OK Content-Type: text/plain Transfer-Encoding: chunked <script>eval("... ")</script>0 <script>eval("... ")</script>0
  10. 10. Periodic polling Poll from time to time using Ajax Delay in communications due to polling interval Wastes bandwidth & latency  Polling interval
  11. 11. Long polling Poll but don’t respond until there’s data Poll again after data received or after the connection times out Consumes server threads & connection resources 
  12. 12. Options! Forever Frame Periodic polling Long polling Websockets (Server-Sent events)
  13. 13. SignalR
  14. 14. SignalR Three-in-one! “Persistent” client/server connection over best transport Connection negotiation Abstracts away the transport Provides just one programming model http://github.com/signalr/signalr - open source C#, JavaScript, UWP https://github.com/aspnet/signalr - new .NET Core version
  15. 15. Hello, SignalR DEMO
  16. 16. What just happened? The server is broadcasting a message every few seconds Clients are receiving messages Code looks easy No polling or whatsoever (at least not in my code) SignalR decides on transport mechanism used based on client + server
  17. 17. Connections and Hubs
  18. 18. Two programming models PERSISTENT CONNECTION Can communicate with 1..N clients Requires a route to be defined Limited to sending messages You define the “protocol” HUB Abstraction over PersistentConnection Can communicate with 1..N clients Route automatically mapped (/signalr/hubs) Can send messages and call methods SignalR defines the protocol
  19. 19. Hello, Hubs DEMO
  20. 20. Hubs Hub methods can be called from client Client methods can be called from hub Target individual client Target all clients Target group of clients http://shootr.signalr.net/
  21. 21. Clients
  22. 22. So far we have used... On the server side Host in any ASP.NET application (SignalR.Server) On the client side JavaScript (SignalR.JS) But there’s more…
  23. 23. Connecting to SignalR DEMO
  24. 24. There is more! On the server side Host in any ASP.NET application (SignalR.Server) or using self-hosting (OWIN based) Host on Azure Scale out (Redis, Azure Service Bus) (I did a NodeJS server as well, but don’t use it in production) On the client side JavaScript (SignalR.JS), Angular (AngularJs.SignalR.Hub) Any .NET client (SignalR.Client) UWP iOS Android
  25. 25. DeckCast DEMO
  26. 26. .NET Core
  27. 27. ASP.NET Core Sockets SignalR in the ASP.NET Core world Improvements based on SignalR learnings: No more jQuery No more iframe transport No more message replay after reconnect (memory usage, performance) No more Hub-state (I did not talk about this “ViewState” because it’s evil) Endpoint per Hub (/signalr/hubs  /signalr/...) Scale-out now becomes scale-out (and not sending all messages everywhere) Sticky sessions required (sad )
  28. 28. ASP.NET Core Sockets New features: Cross-platform (including things like RaspberryPi) Binary data support (think sending images etc.) Host-agnostic (HTTP works but also TCP/UDP/... sockets) Protocol data format pluggable (JSON, protobuf, ...) TypeScript client ...
  29. 29. Demo? Will leave this one for you... Under development! https://github.com/aspnet/signalr Preview release mid-year Release later this year
  30. 30. Conclusion
  31. 31. Conclusion SignalR is three-in-one! “Persistent” client/server connection over best transport Abstracts away the transport Provides just one programming model Connections & Hubs Connect various clients
  32. 32. Thank you! http://blog.maartenballiauw.be @maartenballiauw

Today’s users are interested in a rich experience where the terms client and server don’t mean a thing. They expect real-time action between both, no matter if the technology used is HTML5 websockets or something else. This session will cover SignalR and show you how it can be used to communicate in real time between the client and server, using HTML5 or not. Combine SignalR with ASP.NET MVC, JavaScript and perhaps a sprinkle of Azure and you’ll have an interesting, reliable and fast stack to build your real-time client-server and server-client communications. Join me on this journey between web, cloud and user. No toothpaste. Just code.

Views

Total views

1,266

On Slideshare

0

From embeds

0

Number of embeds

1

Actions

Downloads

14

Shares

0

Comments

0

Likes

0

×