SlideShare une entreprise Scribd logo
1  sur  23
SignalR
Mariano Sánchez
Lagash Systems
marianos@lagash.com
¿Por que necesitamos aplicaciones
real-time?
¡Los usuarios quieren la ultima
informacion AHORA!
Twitter – live searches/updates
Stock streamers
Auctions
Live scores
Real-time notifications
Interactive games
Collaborative apps
Live user analytics
…
6
¿Que tecnologias tenemos hoy?
HTTP no esta preparado…
Nunca se diseño para comunicaciones real-time
La web es request-response
La web es stateless
Para solucionar esto se invento
HTML5 WebSockets
HTTP/1.1 200 OK
Content-Type: text/plain
Transfer-Encoding: chunked
Forever Frame
– El server le dice al cliente que el response es chuncked
– El cliente mantiene la coneccion abierta hasta que el
servidor la cierra
– El servidor envia los datos al cliente seguido de un 0
– Este proceso consume threads del servidor
<script>eval("... ")</script>0
<script>eval("... ")</script>0
Periodic polling
– Cada cierto tiempo el cliente pregunta si hay nuevos datos
al servidor utilizando Ajax
– El tiempo de latencia minimo esta determiando por el
“polling interval”
– Desperdicia ancho de banda y latencia 
Polling interval
Long polling
– El cliente pregunta pero el servidor no responde hasta que
tenga datos nuevos para enviar
– El cliente pregunta de nuevo cuando los datos son recibidos
o despues de que hay una time out en al coneccion
– Consume threads y conexiones del servidor 
HTML5 Websockets
ExtensiondeHTTP
ProveesocketssobreHTTP
Full-duplex
Funcionaatravezdeproxies
Todaviaesundraft…
Notodoslosproxyserverslosoportan
Notodosloswebserverlosoportan
Notodoslosbrowserslosoportan
¡Sonsockets!
En definitiva:
¡Muchas opciones!
• Forever Frame
• Periodic polling
• Long polling
• HTML5 WebSockets
SignalR
¡3 en uno!
• Conexiones “persistentes” entre cliente y
servidor sobre el mejor transporte
• Abstrae el modelo de poolling subyasente
• Provee un solo modelo de programacion
DEMO
Hello SignalR
¿Que paso?
• El servidor hizo broadcasting del mensaje
enviado
• Los clientes recibieron los mensajes
• ¡El codigo para todo esto es facil!
• No hay polling (por lo menos no en el codigo)
Dos modelos de conexion
PersistentConnection
Comunica 1..N clientes
Es un IHttpHandler
Requiere que se defina una ruta
Limitado a enviar mensajes
El usuario define el “protocolo”
Hubs
Comunica 1..N clientes
Abstraccion sobre
PersistentConnection
Las rutas se mapean
automaticamente (/signalr/hubs)
Se pueden enviar mensajes y llamar a
metodos
SignalR define el protocolo
Hubs
• Los metodos de un Hub se pueden llamar
desde el cliente
• Los metodos de un cliente se pueden llamar
desde el servidor
– Se pueden llamar a clientes individuales
– Se pueden llamar todos clientes
– Se pueden llamar a grupos de clientes
Demo
Hubs
Clients
Clientes
En el servidor
Se puede hostear en cualquier aplicacion ASP.NET
En el cliente
JavaScript
Pero hay mas…
Clientes
En el servidor
“SelfHost”
Windows Azure
En el cliente
JavaScript
Cualquier aplicacion .NET
Cualquier dispositivo Windows Phone
iOS
Android
Preguntas?
¡Gracias!

Contenu connexe

En vedette

Characteristics of life
Characteristics of lifeCharacteristics of life
Characteristics of lifeMRDM3
 
the internet and world wide web
 the internet and world wide web the internet and world wide web
the internet and world wide webPros Gayo
 
Mejorador de flujo cacalilao mextra
Mejorador de flujo cacalilao mextraMejorador de flujo cacalilao mextra
Mejorador de flujo cacalilao mextraIrving1601
 
Uses of Different Shot Types
Uses of Different Shot TypesUses of Different Shot Types
Uses of Different Shot Typesmrstardom
 
19th March Session 2 By Anuradha Das Mathur
19th March Session 2 By Anuradha Das Mathur19th March Session 2 By Anuradha Das Mathur
19th March Session 2 By Anuradha Das MathurSharath Kumar
 
هل هناك مايزعجك؟؟!!
هل هناك مايزعجك؟؟!!هل هناك مايزعجك؟؟!!
هل هناك مايزعجك؟؟!!moath Al-Baltan
 
Davies &Payne 1982 Sabah faunal survey
Davies &Payne 1982 Sabah faunal surveyDavies &Payne 1982 Sabah faunal survey
Davies &Payne 1982 Sabah faunal surveyJunaidi Payne
 
Ed6620 edmodo presentation
Ed6620 edmodo presentationEd6620 edmodo presentation
Ed6620 edmodo presentationRoxanne Gibbons
 
Cuentos 2008 De Cristian Carcamo
Cuentos 2008 De Cristian CarcamoCuentos 2008 De Cristian Carcamo
Cuentos 2008 De Cristian Carcamoguestefe2634
 
Curriculum Vitae English
Curriculum Vitae EnglishCurriculum Vitae English
Curriculum Vitae EnglishAveira Cartoon
 

En vedette (15)

Thermax - CWSS Group
Thermax - CWSS GroupThermax - CWSS Group
Thermax - CWSS Group
 
Texto Marcelo Lagos
Texto Marcelo LagosTexto Marcelo Lagos
Texto Marcelo Lagos
 
Characteristics of life
Characteristics of lifeCharacteristics of life
Characteristics of life
 
Offset y punta seca
Offset y punta secaOffset y punta seca
Offset y punta seca
 
the internet and world wide web
 the internet and world wide web the internet and world wide web
the internet and world wide web
 
Mejorador de flujo cacalilao mextra
Mejorador de flujo cacalilao mextraMejorador de flujo cacalilao mextra
Mejorador de flujo cacalilao mextra
 
L5
L5L5
L5
 
Uses of Different Shot Types
Uses of Different Shot TypesUses of Different Shot Types
Uses of Different Shot Types
 
Cómo consultar la bibliografía recomendada en el catálogo Trobes
Cómo consultar la bibliografía recomendada en el catálogo TrobesCómo consultar la bibliografía recomendada en el catálogo Trobes
Cómo consultar la bibliografía recomendada en el catálogo Trobes
 
19th March Session 2 By Anuradha Das Mathur
19th March Session 2 By Anuradha Das Mathur19th March Session 2 By Anuradha Das Mathur
19th March Session 2 By Anuradha Das Mathur
 
هل هناك مايزعجك؟؟!!
هل هناك مايزعجك؟؟!!هل هناك مايزعجك؟؟!!
هل هناك مايزعجك؟؟!!
 
Davies &Payne 1982 Sabah faunal survey
Davies &Payne 1982 Sabah faunal surveyDavies &Payne 1982 Sabah faunal survey
Davies &Payne 1982 Sabah faunal survey
 
Ed6620 edmodo presentation
Ed6620 edmodo presentationEd6620 edmodo presentation
Ed6620 edmodo presentation
 
Cuentos 2008 De Cristian Carcamo
Cuentos 2008 De Cristian CarcamoCuentos 2008 De Cristian Carcamo
Cuentos 2008 De Cristian Carcamo
 
Curriculum Vitae English
Curriculum Vitae EnglishCurriculum Vitae English
Curriculum Vitae English
 

Similaire à Introducción a SignalR

Aplicaciones Real-Time con SignalR
Aplicaciones Real-Time con SignalRAplicaciones Real-Time con SignalR
Aplicaciones Real-Time con SignalRRodolfo Finochietti
 
Ajax reverse (Comet) con ASP.NET MVC - JUTI 2011
Ajax reverse (Comet) con ASP.NET MVC - JUTI 2011Ajax reverse (Comet) con ASP.NET MVC - JUTI 2011
Ajax reverse (Comet) con ASP.NET MVC - JUTI 2011Desarrollos NEA
 
1.4 tecnologiasWeb.ppt
1.4 tecnologiasWeb.ppt1.4 tecnologiasWeb.ppt
1.4 tecnologiasWeb.pptJaime Ramos
 
Estrategias Web para notifiaciones
Estrategias Web para notifiacionesEstrategias Web para notifiaciones
Estrategias Web para notifiacionesMariano German Egui
 
Aplicaciones en tiempo real con nodejs y html5
Aplicaciones en tiempo real con nodejs y html5Aplicaciones en tiempo real con nodejs y html5
Aplicaciones en tiempo real con nodejs y html5programadoresmx
 
App en tiempo real con HTML5+Node.js+Socket.IO
App en tiempo real con HTML5+Node.js+Socket.IOApp en tiempo real con HTML5+Node.js+Socket.IO
App en tiempo real con HTML5+Node.js+Socket.IOWalter Gerez
 
T2 aplicaciones-web
T2   aplicaciones-webT2   aplicaciones-web
T2 aplicaciones-webloloky98
 
Azure Realtime analytics: Análisis de datos en tiempo real
Azure Realtime analytics: Análisis de datos en tiempo realAzure Realtime analytics: Análisis de datos en tiempo real
Azure Realtime analytics: Análisis de datos en tiempo realSoftware Guru
 
Generación de web sites dinámicos usando php
Generación de web sites dinámicos usando phpGeneración de web sites dinámicos usando php
Generación de web sites dinámicos usando phpvictdiazm
 
Generacion de web sites dinamico
Generacion de web sites dinamicoGeneracion de web sites dinamico
Generacion de web sites dinamicoJose Luis Crespo
 
SOA multiplataforma con rabbitmq y websockets
SOA multiplataforma con rabbitmq y websocketsSOA multiplataforma con rabbitmq y websockets
SOA multiplataforma con rabbitmq y websocketsbmegias
 
Apuntes materia entorno cliente servidor
Apuntes materia entorno cliente servidorApuntes materia entorno cliente servidor
Apuntes materia entorno cliente servidorMalteadas
 

Similaire à Introducción a SignalR (20)

Aplicaciones Real-Time con SignalR
Aplicaciones Real-Time con SignalRAplicaciones Real-Time con SignalR
Aplicaciones Real-Time con SignalR
 
ASP.NET MVC
ASP.NET MVCASP.NET MVC
ASP.NET MVC
 
Tips aspnet
Tips aspnetTips aspnet
Tips aspnet
 
Introduccion SignalR
Introduccion SignalRIntroduccion SignalR
Introduccion SignalR
 
Ajax reverse (Comet) con ASP.NET MVC - JUTI 2011
Ajax reverse (Comet) con ASP.NET MVC - JUTI 2011Ajax reverse (Comet) con ASP.NET MVC - JUTI 2011
Ajax reverse (Comet) con ASP.NET MVC - JUTI 2011
 
ASP.NET MVC Workshop Día 3
ASP.NET MVC Workshop Día 3ASP.NET MVC Workshop Día 3
ASP.NET MVC Workshop Día 3
 
1.4 tecnologiasWeb.ppt
1.4 tecnologiasWeb.ppt1.4 tecnologiasWeb.ppt
1.4 tecnologiasWeb.ppt
 
Estrategias Web para notifiaciones
Estrategias Web para notifiacionesEstrategias Web para notifiaciones
Estrategias Web para notifiaciones
 
Servidor push
Servidor pushServidor push
Servidor push
 
Aplicaciones en tiempo real con nodejs y html5
Aplicaciones en tiempo real con nodejs y html5Aplicaciones en tiempo real con nodejs y html5
Aplicaciones en tiempo real con nodejs y html5
 
Iba2008 Servicios
Iba2008 ServiciosIba2008 Servicios
Iba2008 Servicios
 
App en tiempo real con HTML5+Node.js+Socket.IO
App en tiempo real con HTML5+Node.js+Socket.IOApp en tiempo real con HTML5+Node.js+Socket.IO
App en tiempo real con HTML5+Node.js+Socket.IO
 
T2 aplicaciones-web
T2   aplicaciones-webT2   aplicaciones-web
T2 aplicaciones-web
 
Azure Realtime analytics: Análisis de datos en tiempo real
Azure Realtime analytics: Análisis de datos en tiempo realAzure Realtime analytics: Análisis de datos en tiempo real
Azure Realtime analytics: Análisis de datos en tiempo real
 
Generación de web sites dinámicos usando php
Generación de web sites dinámicos usando phpGeneración de web sites dinámicos usando php
Generación de web sites dinámicos usando php
 
Generacion de web sites dinamico
Generacion de web sites dinamicoGeneracion de web sites dinamico
Generacion de web sites dinamico
 
Social Erlang
Social ErlangSocial Erlang
Social Erlang
 
SOA multiplataforma con rabbitmq y websockets
SOA multiplataforma con rabbitmq y websocketsSOA multiplataforma con rabbitmq y websockets
SOA multiplataforma con rabbitmq y websockets
 
Apuntes materia entorno cliente servidor
Apuntes materia entorno cliente servidorApuntes materia entorno cliente servidor
Apuntes materia entorno cliente servidor
 
Bosquejo general
Bosquejo generalBosquejo general
Bosquejo general
 

Plus de Mariano Sánchez

Plus de Mariano Sánchez (18)

.NET Core
.NET Core.NET Core
.NET Core
 
ASP.NET Core 1.0
ASP.NET Core 1.0ASP.NET Core 1.0
ASP.NET Core 1.0
 
Visual Studio LightSwitch
Visual Studio LightSwitchVisual Studio LightSwitch
Visual Studio LightSwitch
 
HTML5 + Asp.NET
HTML5 + Asp.NETHTML5 + Asp.NET
HTML5 + Asp.NET
 
Hey Cortana!
Hey Cortana!Hey Cortana!
Hey Cortana!
 
Developing Universal Apps for Windows
Developing Universal Apps for WindowsDeveloping Universal Apps for Windows
Developing Universal Apps for Windows
 
Introducing the Windows Phone 8.1 App Development Platform
Introducing the Windows Phone 8.1 App Development PlatformIntroducing the Windows Phone 8.1 App Development Platform
Introducing the Windows Phone 8.1 App Development Platform
 
Visual Studio Online
Visual Studio OnlineVisual Studio Online
Visual Studio Online
 
Patrones Grasp
Patrones GraspPatrones Grasp
Patrones Grasp
 
Patrones de Diseño
Patrones de DiseñoPatrones de Diseño
Patrones de Diseño
 
Introducción a DDD
Introducción a DDDIntroducción a DDD
Introducción a DDD
 
Conociendo TypeScript
Conociendo TypeScriptConociendo TypeScript
Conociendo TypeScript
 
C# 6 - Que hay de nuevo?
C# 6 - Que hay de nuevo?C# 6 - Que hay de nuevo?
C# 6 - Que hay de nuevo?
 
Universal Windows Platform Programando para todos y todas
Universal Windows PlatformProgramando para todos y todasUniversal Windows PlatformProgramando para todos y todas
Universal Windows Platform Programando para todos y todas
 
Code Smells
Code SmellsCode Smells
Code Smells
 
Introducción a LINQ
Introducción a LINQIntroducción a LINQ
Introducción a LINQ
 
Refactoring - Mejorando el diseño del código existente
Refactoring - Mejorando el diseño del código existenteRefactoring - Mejorando el diseño del código existente
Refactoring - Mejorando el diseño del código existente
 
Patrones de Diseño
Patrones de DiseñoPatrones de Diseño
Patrones de Diseño
 

Dernier

SISTEMA INTEGRADO DE ADMINISTRACION FINANCIERA - SIAF MODULO ADMINISTRATIVO
SISTEMA INTEGRADO DE ADMINISTRACION FINANCIERA - SIAF MODULO ADMINISTRATIVOSISTEMA INTEGRADO DE ADMINISTRACION FINANCIERA - SIAF MODULO ADMINISTRATIVO
SISTEMA INTEGRADO DE ADMINISTRACION FINANCIERA - SIAF MODULO ADMINISTRATIVOELIAMARYTOVARFLOREZD
 
Presentación de html, css y javascript.
Presentación  de html, css y javascript.Presentación  de html, css y javascript.
Presentación de html, css y javascript.CeteliInmaculada
 
Semana 5-Conceptualización del lenguaje de programación C++
Semana 5-Conceptualización del lenguaje de programación C++Semana 5-Conceptualización del lenguaje de programación C++
Semana 5-Conceptualización del lenguaje de programación C++luzgaray6
 
MacOS SISTEMA OPERATIVO CARACTERISTICAS.pptx
MacOS SISTEMA OPERATIVO CARACTERISTICAS.pptxMacOS SISTEMA OPERATIVO CARACTERISTICAS.pptx
MacOS SISTEMA OPERATIVO CARACTERISTICAS.pptxcalzadillasluis134
 
Introducción a Plone CMS - World Plone Day 2024
Introducción a Plone CMS - World Plone Day 2024Introducción a Plone CMS - World Plone Day 2024
Introducción a Plone CMS - World Plone Day 2024Leonardo J. Caballero G.
 
Theme design in Plone 6 - World Plone Day 2024
Theme design in Plone 6 - World Plone Day 2024Theme design in Plone 6 - World Plone Day 2024
Theme design in Plone 6 - World Plone Day 2024Leonardo J. Caballero G.
 

Dernier (6)

SISTEMA INTEGRADO DE ADMINISTRACION FINANCIERA - SIAF MODULO ADMINISTRATIVO
SISTEMA INTEGRADO DE ADMINISTRACION FINANCIERA - SIAF MODULO ADMINISTRATIVOSISTEMA INTEGRADO DE ADMINISTRACION FINANCIERA - SIAF MODULO ADMINISTRATIVO
SISTEMA INTEGRADO DE ADMINISTRACION FINANCIERA - SIAF MODULO ADMINISTRATIVO
 
Presentación de html, css y javascript.
Presentación  de html, css y javascript.Presentación  de html, css y javascript.
Presentación de html, css y javascript.
 
Semana 5-Conceptualización del lenguaje de programación C++
Semana 5-Conceptualización del lenguaje de programación C++Semana 5-Conceptualización del lenguaje de programación C++
Semana 5-Conceptualización del lenguaje de programación C++
 
MacOS SISTEMA OPERATIVO CARACTERISTICAS.pptx
MacOS SISTEMA OPERATIVO CARACTERISTICAS.pptxMacOS SISTEMA OPERATIVO CARACTERISTICAS.pptx
MacOS SISTEMA OPERATIVO CARACTERISTICAS.pptx
 
Introducción a Plone CMS - World Plone Day 2024
Introducción a Plone CMS - World Plone Day 2024Introducción a Plone CMS - World Plone Day 2024
Introducción a Plone CMS - World Plone Day 2024
 
Theme design in Plone 6 - World Plone Day 2024
Theme design in Plone 6 - World Plone Day 2024Theme design in Plone 6 - World Plone Day 2024
Theme design in Plone 6 - World Plone Day 2024
 

Introducción a SignalR

Notes de l'éditeur

  1. How do you implement these today?
  2. DEMO: Fiddler con hootsuit.com
  3. DEMO: Fiddler con facebook.com
  4. That’s a lot of options, a lot of things to account for and a lot of different programming models. Are you going to do this? Are you still writing separate getDocumentById and AttachEvent methods to work with the DOM? What about jQuery?
  5. Open the previously created sample Install-Package jQuery.UI.Combined Add a class: [HubName("worker")] public class WorkerHub : Hub { public void startProcessing(Event e) { Caller.notify("We've started processing " + e.EventName); Clients.setProgress(10); for (int i = 0; i <= 100; i++) { SignalR.Hubs.Hub.GetClients<WorkerHub>().setProgress(i); Thread.Sleep(100); } } } Add some HTML: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <link rel="stylesheet" href="Content/themes/base/jquery.ui.all.css" /> <script src="Scripts/jquery-1.6.4.min.js" type="text/javascript"></script> <script src="Scripts/jquery-ui-1.8.16.min.js" type="text/javascript"></script> <script src="Scripts/jquery.signalR.js" type="text/javascript"></script> <script src="signalr/hubs" type="text/javascript"></script> <script type="text/javascript"> $(function () { var workerHub = $.connection.worker; $('#progressbar').progressbar({ value: 0 }); $('#startWorkTrigger').bind('click', function () { workerHub.startProcessing({ eventName: 'UAN12' }) .fail(function (e) { alert("An error occured: " + e); }); }); workerHub.notify = function (message) { $('#notifications').html(message); }; workerHub.setProgress = function (progress) { $('#progressbar').progressbar({ value: progress }); }; $.connection.hub.start(); }); </script> </head> <body> <div id="progressbar" style="width: 200px;"></div> <div id="notifications" style="width: 200px;"></div> <button id="startWorkTrigger">Start work</button></body> </html>