Pushing realtime data to the client
- Library which abtracts communications from ASP.NET server directly to clients
Uses a variety of methods depending on
- Network conditions/firewall
- Browser capability
- HTML 5 WebSockets
- Server Sent Events
- Forever Frame
- Ajax Long Polling
- Allows you to send async messages from server to client, or client to server
History SignalR Project
- Created July, 2011 by David Fowler as moonlighting project
- Found that Damian Edward was working on a similiar project
- So they merged their code and combined effort
- MIT Licensed, hosted on GitHub
- IE 8+, Chrome, Safari, Firefox, Opera
- Mobile: Android, iOS, Windows Mobile
- .NET (winForm, WPF, Silverlight, Mono)
- iOS Native Apps (3rd party)
- Android Native Apps (3rd party)
- Windows Server 2012, 2008r2
- Windows 8, 7
- Windows Azure
- Server components written for .NET 4.5
Generally hosted in web app
- Websockets rely on IIS 8.0
- Can also be self hosted in windows service or console app.
Modes of development
Low level API for sending bits to client
- Broadcasts an object directly to a set of clients
- Client is responsible for routing the message within the page
- Generally won't use this method.
- Main abstraction used in SignalR
- Represents a set of clients connected to the same "channel"
Shared educational experiences
- As I move, you move
- Transmits messages to everyone connected to hub
- Server pushes data to clients as soon as it is changed
- Some sort of watcher on the server
- As soon as data changes, broadcast to all clients
- Broadcast deltas, or entire set of data
- Clients need an initial set of data when page is loaded
Long running transaction
- Allows you to provide realtime feedback to customer
- Need to send in a connection id, or group name to your transaction processor
- SignalR will reconnect if network connection drops
- Good way to instill confidence in your system
Allows many people to work on documents together
- And see the outcome together
- Clients need to download an initial set of data.
- Should be handling reconnection event.
- Need to make provisions for concurrency.
- A single server can handle 1000's of connections
- Scales out to multiple servers using a shared backend
Out of the box providers include
- SQL Server
- Azure service bus
- Extensible so that you can create your own provider
- Bound by allowable connections to IIS
- Uses ASP.NET security providers
By default won't work cross-domain
Enable using CORS library.
Specific points of extensibility
- Message bus transport
- Assembly locator to search for hubs within
- JSON serializer
All in all
- SignalR is a very useful library to allow bidirectional communication between client and server
- Supports many different devices.
- Bidirection communication is harder than poll.