SignalR - Code, not toothpaste - UGIALT.NET
-
Upload
maarten-balliauw -
Category
Technology
-
view
11.018 -
download
2
description
Transcript of SignalR - Code, not toothpaste - UGIALT.NET
APRIL 12, 2023 | SLIDE 1
APRIL 12, 2023 | SLIDE 2
www.realdolmen.com
USING SIGNALR FOR REALTIME CLIENT/SERVER COMMUNICATION
@
My name is
I’m from
I blog at
maartenballiauw
Maarten Balliauw
Belgium
http://blog.maartenballiauw.be
APRIL 12, 2023 | SLIDE 4
WHO AM I?
Maarten Balliauw Antwerp, Belgium www.realdolmen.com Focus on web
ASP.NET MVC, PHP, Azure, SignalR, … MVP Windows Azure (formerly ASP.NET)
Co-founder of AZUG http://blog.maartenballiauw.be @maartenballiauw
APRIL 12, 2023 | SLIDE 5
AGENDA
Why real-time & how? Meet SignalR Connections and Hubs Clients Q&A
APRIL 12, 2023 | SLIDE 6
WHY REAL-TIME & HOW?
APRIL 12, 2023 | SLIDE 7
USERS WANT THE LATEST INFORMATION, NOW! Twitter – live searches/updates Stock streamers Auctions Live scores New e-mail Real-time notifications Interactive games Collaborative apps Analytics of users …
APRIL 12, 2023 | SLIDE 8
HTTP IS AN OLD BEAST…
Never designed for real-time communications Web is request-response Web is stateless
But…
HTML5 WebSockets to the rescue, right?
APRIL 12, 2023 | SLIDE 9
HTML5 WEBSOCKETS
Extension to HTTP Provide raw sockets over HTTP Full-duplex Traverses proxies
It’s still a draft… Not every proxy server supports it Not every webserver supports it Not every browser supports it They are raw sockets!
APRIL 12, 2023 | SLIDE 10
PERIODIC POLLING
Bottom line: Poll from time to time using Ajax Delay in communications due to polling interval Wastes bandwidth & latency
Polling interval
Client
Server
Fiddlerhootsuite.com
APRIL 12, 2023 | SLIDE 11
LONG POLLING
Bottom line: Poll but don’t respond untill there’s data Poll again after data received or after the connection
times out Consumes server threads & connection resources
Client
Server
Fiddlerfacebook.com
APRIL 12, 2023 | SLIDE 12
WHICH LEAVES US WITH 3 OPTIONS FOR REAL-TIME Periodic polling Long polling HTML5 WebSockets
APRIL 12, 2023 | SLIDE 13
MEET SIGNALR
ARRR!
APRIL 12, 2023 | SLIDE 15
SIGNALR?
Three-in-one! “Persistent” client/server connection over best transport Abstracts away the transport Provides just one programming model
David Fowler and Damian Edwards(two guys on the ASP.NET team)
Not an official Microsoft project (yet?) OSS project on Github, MIT licensed
http://github.com/signalr/signalr Simple to setup & just works Depends on C# (not VB.NET), .NET 4+ and
jQuery
APRIL 12, 2023 | SLIDE 16
WHERE DO I GET IT?
* where else!
*
APRIL 12, 2023 | SLIDE 17
HELLO, SIGNALR!
APRIL 12, 2023 | SLIDE 18
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 in my code)
APRIL 12, 2023 | SLIDE 19
CONNECTIONS AND HUBS
APRIL 12, 2023 | SLIDE 20
TWO CONNECTION MODELS
PersistentConnection Can communicate
with 1..N clients Is an IHttpHandler Requires a route to be
defined Limited to sending
messages You define the
“protocol”
Hubs Can communicate
with 1..N clients Abstraction over
PersistentConnection Route automatically
mapped (/signalr/hubs)
Can send messages and call methods
SignalR defines the protocol
APRIL 12, 2023 | SLIDE 21
HELLO, SIGNALR HUBS!
APRIL 12, 2023 | SLIDE 22
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://jabbr.net
APRIL 12, 2023 | SLIDE 23
CLIENTS
APRIL 12, 2023 | SLIDE 24
SO FAR WE’VE USED…
On the server side: Host in any ASP.NET application (SignalR.Server)
On the client side: JavaScript (SignalR.JS)
But there’s more…
APRIL 12, 2023 | SLIDE 25
DECKCAST
APRIL 12, 2023 | SLIDE 26
THAT’S A LOT MORE!
On the server side: Host in any ASP.NET application (SignalR.Server) Use “SelfHost”
https://github.com/SignalR/SignalR/tree/master/SignalR.SelfHost
On the client side: JavaScript (SignalR.JS) Any .NET client (SignalR.Client) Any WP7 device (SignalR.Client.WP7) iOS Android
Is this becoming a replacement for WCF?
APRIL 12, 2023 | SLIDE 27
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 Make the web real-time!
APRIL 12, 2023 | SLIDE 28
RESOURCES
My blog:http://blog.maartenballiauw.be
SignalR on Github:http://github.com/signalr/signalr
SignalR on NuGet:http://www.nuget.org/packages?q=signalr
Websockets: http://github.com/signalr/signalr.websockets
Scale-out on Windows Azure: http://github.com/signalr/signalr.azure
Objective C client: https://github.com/DyKnow/SignalR-ObjC
Android client (using MonoDroid): https://github.com/SignalR/SignalR/pull/127
APRIL 12, 2023 | SLIDE 29
Q&A
APRIL 12, 2023 | SLIDE 30
THANK YOU FOR JOINING
@
My name is
I’m from
I blog at
maartenballiauw
Maarten Balliauw
Belgium
http://blog.maartenballiauw.be