The presentation is a really short introduction. To get the most of it you should go to: https://github.com/mastoj/SignalRPres where I have some really small sample projects. If you have installed redis, follow the instructions here https://github.com/MSOpenTech/Redis, and uses IIS express you can try running scale out with the MyFarm.ps1 script in this folder: https://github.com/mastoj/SignalRPres/tree/master/Chatty/Chatty.
7. WHAT IS SIGNALR?
Abstraction over persistent connections
Asynchronous scalable web applications
It’s like Socket.IO and nowjs (nodejs) for .NET
8. HOW?
1. Install-package Microsoft.AspNet.SignalR -pre (-pre when pre-release)
2. Server
[HubName("simple")]
public class SimpleHub : Hub
{
public void CallOut(string message)
{
Clients.Others(message);
}
}
3. Client
$(function() {
var simpleHub = $.connection.simple;
$.extend(simpleHub.client, {
echo: function(message) { alert(message); }
});
$("#some-button").click(function() {
simpleHub.server.callOut("Echo");
});
});
9. DEMO TIME!
1. Persistent connection
2. Chat
3. Chat with Redis
4. (Windows app client) – if there is time
10. SCALE OUT
pub/sub
Server 1 Server 2
Client 1 Client 2 Client 3 Client 4 Client 5 Client 6
11. SUMMARY
• Async web is coming for you
• Collaboration, real-time and notification systems
• SignalR is a simple to use persistent connection abstraction for .NET
12. RESOURCE
• Demo projects: https://github.com/mastoj/SignalRPres
• SignalR project page: http://www.signalr.net
• SignalR on github: https://github.com/SignalR/SignalR (good samples)
• Redis for windows: http://tinyurl.com/winredis (Microsoft Open Tech)
I en synkron miljø så tar hvert enkelt request en thread mange request lavere ytelse
Nå er vi ikke avhengig av noen polling tid hvis vi har en «true» persistent connection.Modellen er asyn, så hver connection trenger ikke en egen thread.
Vi trenger abstraktionen då web socket ikke er 100% støttet og å programmere mot socket er vanskeligDet er en abstraktion over en persistent connectionWebSockets --> server sent events --> forever frame --> long pollingWebSockets persistent tcp connectionServer sent events /eventsource one way messaging / client listens to eventsForever frame – En iframe etter sidlasting med en laaang connectionLong polling poll and wait for dataSkallerer bra, lagrer ikke noe state på serveren. Har støtte for scale out gjenom redis og azure service bus som default.
ASP.NET Web API finns demos og forklaringerDemo project kommer med magisk branching graf