Слайд 1Real-time ASP.NET with SignalR
Alex Konduforov
AltexSoft
Слайд 3USERS WANT THE LATEST INFO
NOW!
Слайд 8Other applications
Live scores
Real-time notifications
Interactive games
Collaborative apps
Live user analytics
etc.
Слайд 9Standard solutions
Frequent Polling
Long polling
Server-Sent events (HTML5)
WebSocket (HTML5)
Слайд 10Polling
Get updates frequently using Ajax requests
Pros:
---
Cons:
Delay in results
Wastes bandwidth &
latency
Слайд 11Long polling
Similar to usual polling (Ajax requests)
Request waits longer (1-2
minutes)
Pros:
Lower load on server
No delays
Cons:
Consumes server threads & connection resources
Слайд 12Server-Sent events
HTML5, works over HTTP
EventSource JavaScript API
Content-type: text/event-stream
Pros:
No need to
reconnect
No need in a special protocol or server implementation
Cons:
Works in
server-t0-client direction
Слайд 13WebSocket
HTML5, new protocol (ws:// and wss://) on top of TCP
Pros:
Full-duplex
persistent connection (both ways)
Cons:
Require Web Socket protocol support on client
(IE10)
Require Web Socket protocol support on server (IIS8)
Слайд 16Authors
David Fowler
Damian Edwards
Слайд 17What is SignalR?
Official MS technology to build real-time multi-user ASP.NET
applications: http://signalr.net/
Out-of-box solution that consists of server and client side
Abstraction
over the set of transports
Open-source solution available on GitHub that can be installed via NuGet
Слайд 20Hubs
High-level API
Similar to Controller (actions, thread per call)
Слайд 21Supported scenarios
Client calling the server
Server calling clients (all, group, one)
State
round-tripping between client and server
Binding complex objects (JSON)
Detecting connect, disconnect
and reconnect clients
Broadcasting from outside of a Hub
Async scenarios (return Task/Task to client)
Слайд 22Server calling the client
dynamic Clients property
JSON serialization
Слайд 23Managing Groups
Add/remove connections to groups
Слайд 24Broadcasting from outside
Notify clients from another server-side code
Слайд 25JavaScript client
$.connection.hub
connection for all hubs (url points to /signalr)
$.connection.hub.id
client id
for the hub connection
$.connection.hub.start()
starts the connection for all hubs
$.connection.{hubname}
access a
client side hub from the generated proxy
$.connection.hub.logging
set to true to enable logging
Слайд 26Exposing methods on the client
The JavaScript client can declare methods
that the server can invoke:
myHub.{method} = callback
declares a function the
server can invoke.
method - name of the client side method
callback - function to execute when the server invokes the method
Слайд 29Configuring SignalR
Set in IConfigurationManager:
Слайд 30SignalR extensibility
Pluggable interfaces in SignalR:
You can even replace IDependencyResolver
Слайд 31SignalR and web farm
Available now:
Azure Service Bus
Windows Server Service Bus
SQL
Server
Redis
Coming:
NServiceBus
SQL QNS
etc.
Слайд 32SignalR over Redis
Step 1
Download and install Redis as Windows service
Step
2
Install-Package SignalR.Redis
Step 3
Слайд 33Materials
https://github.com/SignalR
http://jabbr.net
http://www.hanselman.com/blog/CategoryView.aspx?category=SignalR
http://www.asp.net/vnext/overview/signalr/signalr-and-web-sockets
http://merle-amber.blogspot.com/2012/11/real-time-aspnet-signalr.html
Слайд 34Thanks for listening!
merle-amber.blogspot.com
@konduforov
31337