SlideShare una empresa de Scribd logo
1 de 44
CLOUD COMPUTING.
DESARROLLO DE APLICACIONESY
MINERÍA WEB
Programa de extensión universitariaUniversidad de Oviedo
Miguel Fernández Fernández
miguel@ThirdWay.es
Web enTiempo Real
XMPP, Websockets, et al.
¿Qué es XMPP?
Extensible Messaging and Presence Protocol
Envío de mensajes en tiempo real
Codificados en XML
Transportados sobreTCP y UDP (media)
antesJabber
http://xmpp.org
¿Por qué XMPP?
HTTP
Half-duplex
para la Web
stateless
¿Por qué XMPP?
HTTP
Half-duplex
c
s
normal polling (AJAX)
c
s
long polling (Comet)
para la Web
stateless
¿Por qué XMPP?
HTTP
Half-duplex
c
s
normal polling (AJAX)
c
s
long polling (Comet)
para la Web
stateless
XMPP
Full-duplex
stateful
¿Por qué XMPP?
HTTP
Half-duplex
c
s
normal polling (AJAX)
c
s
long polling (Comet)
para la Web
stateless
XMPP
Full-duplex
stateful
c
s
conexión persistente
Arquitectura XMPP
O’REILLY XMPP:The Definitive Guide
Arquitectura XMPP
Web (HTTP) Mail (SMTP)
XMPP
La red XMPP: Entidades
Servidores
Plugins
Componentes
Clientes
Servidores
Enrutan mensajes
Hablan con clientes y otros servidores
FOSS: Ejabberd, Openfire,Tigase
Clientes
Humanos y robots
Protocolo cliente-servidor
Componentes
Extienden la funcionalidad del servidor
Tienen su propia identidad y dirección
Se ejecutan fuera del mismo
Se comunican con un protocolo específico
Ejemplo típico: Multichat
Plugins
Mismo propósito que los componentes
También tienen identidad y dirección
No hay IPC mayor rendimiento
Direccionamiento en XMPP
JIDs: almenos uno por cada entidad
local@dom.ain/resource
it@miinterprete.appspotchat.com/adium
Bare JID
Full JID
XMPP Stanzas
<stream:stream>
<iq type="get">
<query xmlns="jabber:iq:roster"/>
</iq>
<presence/>
<message to="bar@otherside.com" from="foo@oneside.com/adium" type="chat">
<body>Tomamos algo?</body>
</message>
<presence type="unavailable"/>
</stream:stream>
XMPP Stanzas
<stream:stream>
<iq type="get">
<query xmlns="jabber:iq:roster"/>
</iq>
<presence/>
<message to="bar@otherside.com" from="foo@oneside.com/adium" type="chat">
<body>Tomamos algo?</body>
</message>
<presence type="unavailable"/>
</stream:stream>
XMPP Stanzas
<stream:stream>
<iq type="get">
<query xmlns="jabber:iq:roster"/>
</iq>
<presence/>
<message to="bar@otherside.com" from="foo@oneside.com/adium" type="chat">
<body>Tomamos algo?</body>
</message>
<presence type="unavailable"/>
</stream:stream>
Dame mis contactos
XMPP Stanzas
<stream:stream>
<iq type="get">
<query xmlns="jabber:iq:roster"/>
</iq>
<presence/>
<message to="bar@otherside.com" from="foo@oneside.com/adium" type="chat">
<body>Tomamos algo?</body>
</message>
<presence type="unavailable"/>
</stream:stream>
Dame mis contactos
Estoy online
XMPP Stanzas
<stream:stream>
<iq type="get">
<query xmlns="jabber:iq:roster"/>
</iq>
<presence/>
<message to="bar@otherside.com" from="foo@oneside.com/adium" type="chat">
<body>Tomamos algo?</body>
</message>
<presence type="unavailable"/>
</stream:stream>
Dame mis contactos
Estoy online
Dile a bar que si
tomamos algo
XMPP Stanzas
<stream:stream>
<iq type="get">
<query xmlns="jabber:iq:roster"/>
</iq>
<presence/>
<message to="bar@otherside.com" from="foo@oneside.com/adium" type="chat">
<body>Tomamos algo?</body>
</message>
<presence type="unavailable"/>
</stream:stream>
Dame mis contactos
Estoy online
Dile a bar que si
tomamos algoYa no estoy disponible
Tiempo real en La Web
Acercando XMPP a la Web
Pre HTML 5
Comunicación basada en HTTP
Bidirectional-Streams over
synchronous HTTP
AJAX & Long Polling
AJAX & Long Polling
setInterval(function(){
// pedimos cada 500 milisegundos esperando cambio
$.ajax({ url: '/my/page', success: function(data){} });
}, 500);
function load(){
$.ajax({ url: '/my/page', success: function(){
// abrimos la conexión durante 20 segundos
}, complete: load, timeout: 20000 });
}
AJAX (muestreo frecuente) Comet (Long Polling)
Latencia (200ms/petición)
Muchas peticiones no recogeran cambios
Se genera mucho tráfico
Reducción dramática de latencia
Mucho más eficiente
BOSH, XMPP sobre HTTP
http://xmpp.org/extensions/xep-0206.html
Flujos bidireccionales sobre HTTP síncrono
Usa pares de petición-respuesta para simular
Requiere de un proxy que dirija los stanzas al servidor XMPP
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: 483
<body xmpp:version='1.0'
authid='ServerStreamID'
xmlns='http://jabber.org/protocol/httpbind'
xmlns:xmpp='urn:xmpp:xbosh'
xmlns:stream='http://etherx.jabber.org/streams'>
<stream:features>
<mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>
<mechanism>SCRAM-SHA-1</mechanism>
<mechanism>PLAIN</mechanism>
</mechanisms>
</stream:features>
</body>
HTML5 Websockets
HTML 5
WebSockets
To enableWeb applications to maintain bidirectional
communications with server-side processes, this
specification introduces theWebSocket interface.
Gecko 2.0b4 (24/08/2010) (Firefox 4 Nighties)
Webkit 333 (Safari 4, Chrome >4)Soportado en:
HTML5 Websockets
HTML 5
WebSockets
To enableWeb applications to maintain bidirectional
communications with server-side processes, this
specification introduces theWebSocket interface.
Gecko 2.0b4 (24/08/2010) (Firefox 4 Nighties)
Webkit 333 (Safari 4, Chrome >4)Soportado en:
c
s
conexión persistente
El contrato Websocket
[Constructor(in DOMString url, in optional DOMString protocols)]
[Constructor(in DOMString url, in optional DOMString[] protocols)]
interface WebSocket {
readonly attribute DOMString url;
// ready state
const unsigned short CONNECTING = 0;
const unsigned short OPEN = 1;
const unsigned short CLOSING = 2;
const unsigned short CLOSED = 3;
readonly attribute unsigned short readyState;
readonly attribute unsigned long bufferedAmount;
// networking
attribute Function onopen;
attribute Function onmessage;
attribute Function onerror;
attribute Function onclose;
readonly attribute DOMString protocol;
void send(in DOMString data);
void close();
};
WebSocket implements EventTarget;
estado de
la conexión
Recepción de eventos
Envío de mensajes
ws://services.com/service
Web en tiempo real con
Websockets
Event Machine
http://rubyeventmachine.com/
Framework I/O dirigida por eventos
Corre sobre ruby
à-la node.js (javascript) y twisted (python)
Implementa el patrón Reactor
Muy útil para crear aplicaciones servidor
eventmachine (0.12.10)
eventmachine-websocket (0.1.0)
Nuestro cliente<html>
<head>
<script src='jquery.min.js'></script>
<script>
function WebSocketAdapter(url){
this.ws=new WebSocket(url);
this.ws.onmessage = function(evt) {$("#msg").append("<p>"+evt.data+"</p>");};
this.ws.onclose = function() { alert("socket cerrado"); };
this.ws.onopen = function() { alert("conectado..."); };
this.send=function(msg) {this.ws.send(msg);}
}
var ws;
$(document).ready(function(){
ws=new WebSocketAdapter("ws://localhost:8080/");
});
</script>
</head>
<body>
<form>
Enviar al servidor: <input id="texto" type="text" value="hola mundo!"></input>
<input id="enviar" type="button" value="enviar" onclick="ws.send($('#texto').val())"/>
</form>
<div id="msg"></div>
</body>
</html>
Nuestro cliente<html>
<head>
<script src='jquery.min.js'></script>
<script>
function WebSocketAdapter(url){
this.ws=new WebSocket(url);
this.ws.onmessage = function(evt) {$("#msg").append("<p>"+evt.data+"</p>");};
this.ws.onclose = function() { alert("socket cerrado"); };
this.ws.onopen = function() { alert("conectado..."); };
this.send=function(msg) {this.ws.send(msg);}
}
var ws;
$(document).ready(function(){
ws=new WebSocketAdapter("ws://localhost:8080/");
});
</script>
</head>
<body>
<form>
Enviar al servidor: <input id="texto" type="text" value="hola mundo!"></input>
<input id="enviar" type="button" value="enviar" onclick="ws.send($('#texto').val())"/>
</form>
<div id="msg"></div>
</body>
</html>
Nuestro cliente<html>
<head>
<script src='jquery.min.js'></script>
<script>
function WebSocketAdapter(url){
this.ws=new WebSocket(url);
this.ws.onmessage = function(evt) {$("#msg").append("<p>"+evt.data+"</p>");};
this.ws.onclose = function() { alert("socket cerrado"); };
this.ws.onopen = function() { alert("conectado..."); };
this.send=function(msg) {this.ws.send(msg);}
}
var ws;
$(document).ready(function(){
ws=new WebSocketAdapter("ws://localhost:8080/");
});
</script>
</head>
<body>
<form>
Enviar al servidor: <input id="texto" type="text" value="hola mundo!"></input>
<input id="enviar" type="button" value="enviar" onclick="ws.send($('#texto').val())"/>
</form>
<div id="msg"></div>
</body>
</html>
Nuestro cliente<html>
<head>
<script src='jquery.min.js'></script>
<script>
function WebSocketAdapter(url){
this.ws=new WebSocket(url);
this.ws.onmessage = function(evt) {$("#msg").append("<p>"+evt.data+"</p>");};
this.ws.onclose = function() { alert("socket cerrado"); };
this.ws.onopen = function() { alert("conectado..."); };
this.send=function(msg) {this.ws.send(msg);}
}
var ws;
$(document).ready(function(){
ws=new WebSocketAdapter("ws://localhost:8080/");
});
</script>
</head>
<body>
<form>
Enviar al servidor: <input id="texto" type="text" value="hola mundo!"></input>
<input id="enviar" type="button" value="enviar" onclick="ws.send($('#texto').val())"/>
</form>
<div id="msg"></div>
</body>
</html>
Nuestro cliente<html>
<head>
<script src='jquery.min.js'></script>
<script>
function WebSocketAdapter(url){
this.ws=new WebSocket(url);
this.ws.onmessage = function(evt) {$("#msg").append("<p>"+evt.data+"</p>");};
this.ws.onclose = function() { alert("socket cerrado"); };
this.ws.onopen = function() { alert("conectado..."); };
this.send=function(msg) {this.ws.send(msg);}
}
var ws;
$(document).ready(function(){
ws=new WebSocketAdapter("ws://localhost:8080/");
});
</script>
</head>
<body>
<form>
Enviar al servidor: <input id="texto" type="text" value="hola mundo!"></input>
<input id="enviar" type="button" value="enviar" onclick="ws.send($('#texto').val())"/>
</form>
<div id="msg"></div>
</body>
</html>
Nuestro cliente<html>
<head>
<script src='jquery.min.js'></script>
<script>
function WebSocketAdapter(url){
this.ws=new WebSocket(url);
this.ws.onmessage = function(evt) {$("#msg").append("<p>"+evt.data+"</p>");};
this.ws.onclose = function() { alert("socket cerrado"); };
this.ws.onopen = function() { alert("conectado..."); };
this.send=function(msg) {this.ws.send(msg);}
}
var ws;
$(document).ready(function(){
ws=new WebSocketAdapter("ws://localhost:8080/");
});
</script>
</head>
<body>
<form>
Enviar al servidor: <input id="texto" type="text" value="hola mundo!"></input>
<input id="enviar" type="button" value="enviar" onclick="ws.send($('#texto').val())"/>
</form>
<div id="msg"></div>
</body>
</html>
Nuestro cliente<html>
<head>
<script src='jquery.min.js'></script>
<script>
function WebSocketAdapter(url){
this.ws=new WebSocket(url);
this.ws.onmessage = function(evt) {$("#msg").append("<p>"+evt.data+"</p>");};
this.ws.onclose = function() { alert("socket cerrado"); };
this.ws.onopen = function() { alert("conectado..."); };
this.send=function(msg) {this.ws.send(msg);}
}
var ws;
$(document).ready(function(){
ws=new WebSocketAdapter("ws://localhost:8080/");
});
</script>
</head>
<body>
<form>
Enviar al servidor: <input id="texto" type="text" value="hola mundo!"></input>
<input id="enviar" type="button" value="enviar" onclick="ws.send($('#texto').val())"/>
</form>
<div id="msg"></div>
</body>
</html>
Echo (single client)
require 'rubygems'
require 'eventmachine-websocket'
EventMachine::WebSocket.start(:host => "0.0.0.0", :port => 8080) do |con|
con.on_open { con.send "Cliente conectado"}
con.on_message { |msg| con.send msg.reverse }
con.on_close { puts "Cliente desconectado" }
end
Multichat en 23LOC
require 'rubygems'
require 'eventmachine-websocket'
connections=[]
indexes={}
EventMachine::WebSocket.start(:host => "0.0.0.0", :port => 8080) do |con|
con.on_open do
indexes[con]=connections.size+1
con.send "<p class="highlight">Eres el cliente #{indexes[con]}<p>"
connections.each{ |c| c.send "<p class="highlight">El cliente #{indexes[con]} ha entrado en la sala<p>" }
connections << con
end
con.on_message do |msg|
connections.each{ |c| c.send "<p><span class="cliente">Cliente #{indexes[con]}:</span> #{msg}</p>" }
end
con.on_close do
c.send "<p class="highlight">Has abandonado la sala</p>"
connections.delete con
indexes.delete con
end
end
Conclusiones
• Hasta la aparición de HTML5, XMPP tenía unas expectativas
muy altas como alternativa a Comet.
• Sin embargo, se han cancelado muchos servicios XMPP para
el consumo de datos en tiempo real (Twitter firehose API)
• Websocket se presenta como una alternativa más simple y
elegante para la implementación de servicios Web de tiempo
real
• XMPP no pierde fuerza para mensajería instantánea
Bilbiografía
Gracias
CLOUD COMPUTING.
DESARROLLO DE APLICACIONESY
MINERÍA WEB
Programa de extensión universitariaUniversidad de Oviedo
Miguel Fernández Fernández
miguel@ThirdWay.es

Más contenido relacionado

La actualidad más candente

La actualidad más candente (12)

Evitar Ataque a MikroTik Webproxy y DNS cache
Evitar Ataque a MikroTik Webproxy y DNS cacheEvitar Ataque a MikroTik Webproxy y DNS cache
Evitar Ataque a MikroTik Webproxy y DNS cache
 
introduccion a Ajax
introduccion a Ajaxintroduccion a Ajax
introduccion a Ajax
 
Presentacion remobjects
Presentacion remobjectsPresentacion remobjects
Presentacion remobjects
 
Aisi 1415 06 correo
Aisi 1415 06 correoAisi 1415 06 correo
Aisi 1415 06 correo
 
SignalR y dispositivos móviles
SignalR y dispositivos móvilesSignalR y dispositivos móviles
SignalR y dispositivos móviles
 
Tema servlets
Tema servletsTema servlets
Tema servlets
 
Programación web con JSP
Programación web con JSPProgramación web con JSP
Programación web con JSP
 
Integrando Flex Y Spring
Integrando Flex  Y SpringIntegrando Flex  Y Spring
Integrando Flex Y Spring
 
Java Primeros Pasos Revista- Edición 2
Java Primeros Pasos Revista- Edición 2Java Primeros Pasos Revista- Edición 2
Java Primeros Pasos Revista- Edición 2
 
Apache
ApacheApache
Apache
 
Servicios web java, php, perl, google
Servicios web java, php, perl, googleServicios web java, php, perl, google
Servicios web java, php, perl, google
 
Postfix
PostfixPostfix
Postfix
 

Destacado

Yahoo! pipes
Yahoo! pipesYahoo! pipes
Yahoo! pipesThirdWay
 
Screen scraping
Screen scrapingScreen scraping
Screen scrapingThirdWay
 
Ruby On Rails Intro
Ruby On Rails IntroRuby On Rails Intro
Ruby On Rails IntroThirdWay
 
App engine
App engineApp engine
App engineThirdWay
 

Destacado (6)

Yahoo! pipes
Yahoo! pipesYahoo! pipes
Yahoo! pipes
 
Screen scraping
Screen scrapingScreen scraping
Screen scraping
 
Ruby
RubyRuby
Ruby
 
Ruby On Rails Intro
Ruby On Rails IntroRuby On Rails Intro
Ruby On Rails Intro
 
Método silencioso
Método silenciosoMétodo silencioso
Método silencioso
 
App engine
App engineApp engine
App engine
 

Similar a Real time

Introduccion Ajax V1.0
Introduccion Ajax V1.0Introduccion Ajax V1.0
Introduccion Ajax V1.0Arnulfo Gomez
 
Conceptos acerca de Ajax
Conceptos acerca  de AjaxConceptos acerca  de Ajax
Conceptos acerca de AjaxAlvaro Castillo
 
Conceptos Introductorios Del Web 2
Conceptos Introductorios Del Web 2Conceptos Introductorios Del Web 2
Conceptos Introductorios Del Web 2Michelle Aguirre
 
WebService y Reporting
WebService y ReportingWebService y Reporting
WebService y Reportinghvillarreal
 
Clase 5 AJAX - Desarrollo de aplicaciones móviles
Clase 5  AJAX - Desarrollo de aplicaciones móvilesClase 5  AJAX - Desarrollo de aplicaciones móviles
Clase 5 AJAX - Desarrollo de aplicaciones móvilesChristian Cabrera
 
Hacia La Web Sincrona
Hacia La Web SincronaHacia La Web Sincrona
Hacia La Web SincronaIrontec
 
01 Ext Js Introduccion
01 Ext Js   Introduccion01 Ext Js   Introduccion
01 Ext Js IntroduccionMayer Horna
 
AJAX a cuerda Lo básico sobre AJAX y su funcionamiento
AJAX a cuerda
Lo básico sobre AJAX y su funcionamientoAJAX a cuerda
Lo básico sobre AJAX y su funcionamiento
AJAX a cuerda Lo básico sobre AJAX y su funcionamientoRoberto Allende
 
Semana 1 tecnologias web
Semana 1   tecnologias webSemana 1   tecnologias web
Semana 1 tecnologias webINFOVIC
 
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
 

Similar a Real time (20)

Real-time web
Real-time webReal-time web
Real-time web
 
Introduccion Ajax V1.0
Introduccion Ajax V1.0Introduccion Ajax V1.0
Introduccion Ajax V1.0
 
Conceptos acerca de Ajax
Conceptos acerca  de AjaxConceptos acerca  de Ajax
Conceptos acerca de Ajax
 
Conceptos Introductorios Del Web 2
Conceptos Introductorios Del Web 2Conceptos Introductorios Del Web 2
Conceptos Introductorios Del Web 2
 
Servicios web
Servicios webServicios web
Servicios web
 
Ajax
AjaxAjax
Ajax
 
[Code Camp 2009] Aplicaciones de tiempo real con Silverlight y ASP.NET - COME...
[Code Camp 2009] Aplicaciones de tiempo real con Silverlight y ASP.NET - COME...[Code Camp 2009] Aplicaciones de tiempo real con Silverlight y ASP.NET - COME...
[Code Camp 2009] Aplicaciones de tiempo real con Silverlight y ASP.NET - COME...
 
10. consumiendo datos
10. consumiendo datos10. consumiendo datos
10. consumiendo datos
 
WebService y Reporting
WebService y ReportingWebService y Reporting
WebService y Reporting
 
Clase 5 AJAX - Desarrollo de aplicaciones móviles
Clase 5  AJAX - Desarrollo de aplicaciones móvilesClase 5  AJAX - Desarrollo de aplicaciones móviles
Clase 5 AJAX - Desarrollo de aplicaciones móviles
 
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
 
Hacia La Web Sincrona
Hacia La Web SincronaHacia La Web Sincrona
Hacia La Web Sincrona
 
01 Ext Js Introduccion
01 Ext Js   Introduccion01 Ext Js   Introduccion
01 Ext Js Introduccion
 
AJAX EN CURSO PHP
AJAX EN CURSO PHPAJAX EN CURSO PHP
AJAX EN CURSO PHP
 
AJAX a cuerda Lo básico sobre AJAX y su funcionamiento
AJAX a cuerda
Lo básico sobre AJAX y su funcionamientoAJAX a cuerda
Lo básico sobre AJAX y su funcionamiento
AJAX a cuerda Lo básico sobre AJAX y su funcionamiento
 
Servicios web Extendido_error perl
Servicios web Extendido_error perlServicios web Extendido_error perl
Servicios web Extendido_error perl
 
Semana 1 tecnologias web
Semana 1   tecnologias webSemana 1   tecnologias web
Semana 1 tecnologias web
 
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
 
Curso Java Avanzado 2 Servlets
Curso Java Avanzado   2 ServletsCurso Java Avanzado   2 Servlets
Curso Java Avanzado 2 Servlets
 
Tema servlets
Tema servletsTema servlets
Tema servlets
 

Último

trabajotecologiaisabella-240424003133-8f126965.pdf
trabajotecologiaisabella-240424003133-8f126965.pdftrabajotecologiaisabella-240424003133-8f126965.pdf
trabajotecologiaisabella-240424003133-8f126965.pdfIsabellaMontaomurill
 
Instrumentación Hoy_ INTERPRETAR EL DIAGRAMA UNIFILAR GENERAL DE UNA PLANTA I...
Instrumentación Hoy_ INTERPRETAR EL DIAGRAMA UNIFILAR GENERAL DE UNA PLANTA I...Instrumentación Hoy_ INTERPRETAR EL DIAGRAMA UNIFILAR GENERAL DE UNA PLANTA I...
Instrumentación Hoy_ INTERPRETAR EL DIAGRAMA UNIFILAR GENERAL DE UNA PLANTA I...AlanCedillo9
 
KELA Presentacion Costa Rica 2024 - evento Protégeles
KELA Presentacion Costa Rica 2024 - evento ProtégelesKELA Presentacion Costa Rica 2024 - evento Protégeles
KELA Presentacion Costa Rica 2024 - evento ProtégelesFundación YOD YOD
 
PARTES DE UN OSCILOSCOPIO ANALOGICO .pdf
PARTES DE UN OSCILOSCOPIO ANALOGICO .pdfPARTES DE UN OSCILOSCOPIO ANALOGICO .pdf
PARTES DE UN OSCILOSCOPIO ANALOGICO .pdfSergioMendoza354770
 
ATAJOS DE WINDOWS. Los diferentes atajos para utilizar en windows y ser más e...
ATAJOS DE WINDOWS. Los diferentes atajos para utilizar en windows y ser más e...ATAJOS DE WINDOWS. Los diferentes atajos para utilizar en windows y ser más e...
ATAJOS DE WINDOWS. Los diferentes atajos para utilizar en windows y ser más e...FacuMeza2
 
Redes direccionamiento y subredes ipv4 2024 .pdf
Redes direccionamiento y subredes ipv4 2024 .pdfRedes direccionamiento y subredes ipv4 2024 .pdf
Redes direccionamiento y subredes ipv4 2024 .pdfsoporteupcology
 
La era de la educación digital y sus desafios
La era de la educación digital y sus desafiosLa era de la educación digital y sus desafios
La era de la educación digital y sus desafiosFundación YOD YOD
 
Plan de aula informatica segundo periodo.docx
Plan de aula informatica segundo periodo.docxPlan de aula informatica segundo periodo.docx
Plan de aula informatica segundo periodo.docxpabonheidy28
 
Global Azure Lima 2024 - Integración de Datos con Microsoft Fabric
Global Azure Lima 2024 - Integración de Datos con Microsoft FabricGlobal Azure Lima 2024 - Integración de Datos con Microsoft Fabric
Global Azure Lima 2024 - Integración de Datos con Microsoft FabricKeyla Dolores Méndez
 
International Women's Day Sucre 2024 (IWD)
International Women's Day Sucre 2024 (IWD)International Women's Day Sucre 2024 (IWD)
International Women's Day Sucre 2024 (IWD)GDGSucre
 
CLASE DE TECNOLOGIA E INFORMATICA PRIMARIA
CLASE  DE TECNOLOGIA E INFORMATICA PRIMARIACLASE  DE TECNOLOGIA E INFORMATICA PRIMARIA
CLASE DE TECNOLOGIA E INFORMATICA PRIMARIAWilbisVega
 
Trabajo Mas Completo De Excel en clase tecnología
Trabajo Mas Completo De Excel en clase tecnologíaTrabajo Mas Completo De Excel en clase tecnología
Trabajo Mas Completo De Excel en clase tecnologíassuserf18419
 
POWER POINT YUCRAElabore una PRESENTACIÓN CORTA sobre el video película: La C...
POWER POINT YUCRAElabore una PRESENTACIÓN CORTA sobre el video película: La C...POWER POINT YUCRAElabore una PRESENTACIÓN CORTA sobre el video película: La C...
POWER POINT YUCRAElabore una PRESENTACIÓN CORTA sobre el video película: La C...silviayucra2
 
Cortes-24-de-abril-Tungurahua-3 año 2024
Cortes-24-de-abril-Tungurahua-3 año 2024Cortes-24-de-abril-Tungurahua-3 año 2024
Cortes-24-de-abril-Tungurahua-3 año 2024GiovanniJavierHidalg
 
Proyecto integrador. Las TIC en la sociedad S4.pptx
Proyecto integrador. Las TIC en la sociedad S4.pptxProyecto integrador. Las TIC en la sociedad S4.pptx
Proyecto integrador. Las TIC en la sociedad S4.pptx241521559
 
SalmorejoTech 2024 - Spring Boot <3 Testcontainers
SalmorejoTech 2024 - Spring Boot <3 TestcontainersSalmorejoTech 2024 - Spring Boot <3 Testcontainers
SalmorejoTech 2024 - Spring Boot <3 TestcontainersIván López Martín
 
Hernandez_Hernandez_Practica web de la sesion 12.pptx
Hernandez_Hernandez_Practica web de la sesion 12.pptxHernandez_Hernandez_Practica web de la sesion 12.pptx
Hernandez_Hernandez_Practica web de la sesion 12.pptxJOSEMANUELHERNANDEZH11
 
EPA-pdf resultado da prova presencial Uninove
EPA-pdf resultado da prova presencial UninoveEPA-pdf resultado da prova presencial Uninove
EPA-pdf resultado da prova presencial UninoveFagnerLisboa3
 
guía de registro de slideshare por Brayan Joseph
guía de registro de slideshare por Brayan Josephguía de registro de slideshare por Brayan Joseph
guía de registro de slideshare por Brayan JosephBRAYANJOSEPHPEREZGOM
 

Último (19)

trabajotecologiaisabella-240424003133-8f126965.pdf
trabajotecologiaisabella-240424003133-8f126965.pdftrabajotecologiaisabella-240424003133-8f126965.pdf
trabajotecologiaisabella-240424003133-8f126965.pdf
 
Instrumentación Hoy_ INTERPRETAR EL DIAGRAMA UNIFILAR GENERAL DE UNA PLANTA I...
Instrumentación Hoy_ INTERPRETAR EL DIAGRAMA UNIFILAR GENERAL DE UNA PLANTA I...Instrumentación Hoy_ INTERPRETAR EL DIAGRAMA UNIFILAR GENERAL DE UNA PLANTA I...
Instrumentación Hoy_ INTERPRETAR EL DIAGRAMA UNIFILAR GENERAL DE UNA PLANTA I...
 
KELA Presentacion Costa Rica 2024 - evento Protégeles
KELA Presentacion Costa Rica 2024 - evento ProtégelesKELA Presentacion Costa Rica 2024 - evento Protégeles
KELA Presentacion Costa Rica 2024 - evento Protégeles
 
PARTES DE UN OSCILOSCOPIO ANALOGICO .pdf
PARTES DE UN OSCILOSCOPIO ANALOGICO .pdfPARTES DE UN OSCILOSCOPIO ANALOGICO .pdf
PARTES DE UN OSCILOSCOPIO ANALOGICO .pdf
 
ATAJOS DE WINDOWS. Los diferentes atajos para utilizar en windows y ser más e...
ATAJOS DE WINDOWS. Los diferentes atajos para utilizar en windows y ser más e...ATAJOS DE WINDOWS. Los diferentes atajos para utilizar en windows y ser más e...
ATAJOS DE WINDOWS. Los diferentes atajos para utilizar en windows y ser más e...
 
Redes direccionamiento y subredes ipv4 2024 .pdf
Redes direccionamiento y subredes ipv4 2024 .pdfRedes direccionamiento y subredes ipv4 2024 .pdf
Redes direccionamiento y subredes ipv4 2024 .pdf
 
La era de la educación digital y sus desafios
La era de la educación digital y sus desafiosLa era de la educación digital y sus desafios
La era de la educación digital y sus desafios
 
Plan de aula informatica segundo periodo.docx
Plan de aula informatica segundo periodo.docxPlan de aula informatica segundo periodo.docx
Plan de aula informatica segundo periodo.docx
 
Global Azure Lima 2024 - Integración de Datos con Microsoft Fabric
Global Azure Lima 2024 - Integración de Datos con Microsoft FabricGlobal Azure Lima 2024 - Integración de Datos con Microsoft Fabric
Global Azure Lima 2024 - Integración de Datos con Microsoft Fabric
 
International Women's Day Sucre 2024 (IWD)
International Women's Day Sucre 2024 (IWD)International Women's Day Sucre 2024 (IWD)
International Women's Day Sucre 2024 (IWD)
 
CLASE DE TECNOLOGIA E INFORMATICA PRIMARIA
CLASE  DE TECNOLOGIA E INFORMATICA PRIMARIACLASE  DE TECNOLOGIA E INFORMATICA PRIMARIA
CLASE DE TECNOLOGIA E INFORMATICA PRIMARIA
 
Trabajo Mas Completo De Excel en clase tecnología
Trabajo Mas Completo De Excel en clase tecnologíaTrabajo Mas Completo De Excel en clase tecnología
Trabajo Mas Completo De Excel en clase tecnología
 
POWER POINT YUCRAElabore una PRESENTACIÓN CORTA sobre el video película: La C...
POWER POINT YUCRAElabore una PRESENTACIÓN CORTA sobre el video película: La C...POWER POINT YUCRAElabore una PRESENTACIÓN CORTA sobre el video película: La C...
POWER POINT YUCRAElabore una PRESENTACIÓN CORTA sobre el video película: La C...
 
Cortes-24-de-abril-Tungurahua-3 año 2024
Cortes-24-de-abril-Tungurahua-3 año 2024Cortes-24-de-abril-Tungurahua-3 año 2024
Cortes-24-de-abril-Tungurahua-3 año 2024
 
Proyecto integrador. Las TIC en la sociedad S4.pptx
Proyecto integrador. Las TIC en la sociedad S4.pptxProyecto integrador. Las TIC en la sociedad S4.pptx
Proyecto integrador. Las TIC en la sociedad S4.pptx
 
SalmorejoTech 2024 - Spring Boot <3 Testcontainers
SalmorejoTech 2024 - Spring Boot <3 TestcontainersSalmorejoTech 2024 - Spring Boot <3 Testcontainers
SalmorejoTech 2024 - Spring Boot <3 Testcontainers
 
Hernandez_Hernandez_Practica web de la sesion 12.pptx
Hernandez_Hernandez_Practica web de la sesion 12.pptxHernandez_Hernandez_Practica web de la sesion 12.pptx
Hernandez_Hernandez_Practica web de la sesion 12.pptx
 
EPA-pdf resultado da prova presencial Uninove
EPA-pdf resultado da prova presencial UninoveEPA-pdf resultado da prova presencial Uninove
EPA-pdf resultado da prova presencial Uninove
 
guía de registro de slideshare por Brayan Joseph
guía de registro de slideshare por Brayan Josephguía de registro de slideshare por Brayan Joseph
guía de registro de slideshare por Brayan Joseph
 

Real time

  • 1. CLOUD COMPUTING. DESARROLLO DE APLICACIONESY MINERÍA WEB Programa de extensión universitariaUniversidad de Oviedo Miguel Fernández Fernández miguel@ThirdWay.es
  • 2. Web enTiempo Real XMPP, Websockets, et al.
  • 3. ¿Qué es XMPP? Extensible Messaging and Presence Protocol Envío de mensajes en tiempo real Codificados en XML Transportados sobreTCP y UDP (media) antesJabber http://xmpp.org
  • 5. ¿Por qué XMPP? HTTP Half-duplex c s normal polling (AJAX) c s long polling (Comet) para la Web stateless
  • 6. ¿Por qué XMPP? HTTP Half-duplex c s normal polling (AJAX) c s long polling (Comet) para la Web stateless XMPP Full-duplex stateful
  • 7. ¿Por qué XMPP? HTTP Half-duplex c s normal polling (AJAX) c s long polling (Comet) para la Web stateless XMPP Full-duplex stateful c s conexión persistente
  • 9. Arquitectura XMPP Web (HTTP) Mail (SMTP) XMPP
  • 10. La red XMPP: Entidades Servidores Plugins Componentes Clientes
  • 11. Servidores Enrutan mensajes Hablan con clientes y otros servidores FOSS: Ejabberd, Openfire,Tigase
  • 13. Componentes Extienden la funcionalidad del servidor Tienen su propia identidad y dirección Se ejecutan fuera del mismo Se comunican con un protocolo específico Ejemplo típico: Multichat
  • 14. Plugins Mismo propósito que los componentes También tienen identidad y dirección No hay IPC mayor rendimiento
  • 15. Direccionamiento en XMPP JIDs: almenos uno por cada entidad local@dom.ain/resource it@miinterprete.appspotchat.com/adium Bare JID Full JID
  • 16. XMPP Stanzas <stream:stream> <iq type="get"> <query xmlns="jabber:iq:roster"/> </iq> <presence/> <message to="bar@otherside.com" from="foo@oneside.com/adium" type="chat"> <body>Tomamos algo?</body> </message> <presence type="unavailable"/> </stream:stream>
  • 17. XMPP Stanzas <stream:stream> <iq type="get"> <query xmlns="jabber:iq:roster"/> </iq> <presence/> <message to="bar@otherside.com" from="foo@oneside.com/adium" type="chat"> <body>Tomamos algo?</body> </message> <presence type="unavailable"/> </stream:stream>
  • 18. XMPP Stanzas <stream:stream> <iq type="get"> <query xmlns="jabber:iq:roster"/> </iq> <presence/> <message to="bar@otherside.com" from="foo@oneside.com/adium" type="chat"> <body>Tomamos algo?</body> </message> <presence type="unavailable"/> </stream:stream> Dame mis contactos
  • 19. XMPP Stanzas <stream:stream> <iq type="get"> <query xmlns="jabber:iq:roster"/> </iq> <presence/> <message to="bar@otherside.com" from="foo@oneside.com/adium" type="chat"> <body>Tomamos algo?</body> </message> <presence type="unavailable"/> </stream:stream> Dame mis contactos Estoy online
  • 20. XMPP Stanzas <stream:stream> <iq type="get"> <query xmlns="jabber:iq:roster"/> </iq> <presence/> <message to="bar@otherside.com" from="foo@oneside.com/adium" type="chat"> <body>Tomamos algo?</body> </message> <presence type="unavailable"/> </stream:stream> Dame mis contactos Estoy online Dile a bar que si tomamos algo
  • 21. XMPP Stanzas <stream:stream> <iq type="get"> <query xmlns="jabber:iq:roster"/> </iq> <presence/> <message to="bar@otherside.com" from="foo@oneside.com/adium" type="chat"> <body>Tomamos algo?</body> </message> <presence type="unavailable"/> </stream:stream> Dame mis contactos Estoy online Dile a bar que si tomamos algoYa no estoy disponible
  • 22. Tiempo real en La Web
  • 23. Acercando XMPP a la Web Pre HTML 5 Comunicación basada en HTTP Bidirectional-Streams over synchronous HTTP AJAX & Long Polling
  • 24. AJAX & Long Polling setInterval(function(){ // pedimos cada 500 milisegundos esperando cambio $.ajax({ url: '/my/page', success: function(data){} }); }, 500); function load(){ $.ajax({ url: '/my/page', success: function(){ // abrimos la conexión durante 20 segundos }, complete: load, timeout: 20000 }); } AJAX (muestreo frecuente) Comet (Long Polling) Latencia (200ms/petición) Muchas peticiones no recogeran cambios Se genera mucho tráfico Reducción dramática de latencia Mucho más eficiente
  • 25. BOSH, XMPP sobre HTTP http://xmpp.org/extensions/xep-0206.html Flujos bidireccionales sobre HTTP síncrono Usa pares de petición-respuesta para simular Requiere de un proxy que dirija los stanzas al servidor XMPP HTTP/1.1 200 OK Content-Type: text/xml; charset=utf-8 Content-Length: 483 <body xmpp:version='1.0' authid='ServerStreamID' xmlns='http://jabber.org/protocol/httpbind' xmlns:xmpp='urn:xmpp:xbosh' xmlns:stream='http://etherx.jabber.org/streams'> <stream:features> <mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'> <mechanism>SCRAM-SHA-1</mechanism> <mechanism>PLAIN</mechanism> </mechanisms> </stream:features> </body>
  • 26. HTML5 Websockets HTML 5 WebSockets To enableWeb applications to maintain bidirectional communications with server-side processes, this specification introduces theWebSocket interface. Gecko 2.0b4 (24/08/2010) (Firefox 4 Nighties) Webkit 333 (Safari 4, Chrome >4)Soportado en:
  • 27. HTML5 Websockets HTML 5 WebSockets To enableWeb applications to maintain bidirectional communications with server-side processes, this specification introduces theWebSocket interface. Gecko 2.0b4 (24/08/2010) (Firefox 4 Nighties) Webkit 333 (Safari 4, Chrome >4)Soportado en: c s conexión persistente
  • 28. El contrato Websocket [Constructor(in DOMString url, in optional DOMString protocols)] [Constructor(in DOMString url, in optional DOMString[] protocols)] interface WebSocket { readonly attribute DOMString url; // ready state const unsigned short CONNECTING = 0; const unsigned short OPEN = 1; const unsigned short CLOSING = 2; const unsigned short CLOSED = 3; readonly attribute unsigned short readyState; readonly attribute unsigned long bufferedAmount; // networking attribute Function onopen; attribute Function onmessage; attribute Function onerror; attribute Function onclose; readonly attribute DOMString protocol; void send(in DOMString data); void close(); }; WebSocket implements EventTarget; estado de la conexión Recepción de eventos Envío de mensajes ws://services.com/service
  • 29. Web en tiempo real con Websockets
  • 30. Event Machine http://rubyeventmachine.com/ Framework I/O dirigida por eventos Corre sobre ruby à-la node.js (javascript) y twisted (python) Implementa el patrón Reactor Muy útil para crear aplicaciones servidor eventmachine (0.12.10) eventmachine-websocket (0.1.0)
  • 31. Nuestro cliente<html> <head> <script src='jquery.min.js'></script> <script> function WebSocketAdapter(url){ this.ws=new WebSocket(url); this.ws.onmessage = function(evt) {$("#msg").append("<p>"+evt.data+"</p>");}; this.ws.onclose = function() { alert("socket cerrado"); }; this.ws.onopen = function() { alert("conectado..."); }; this.send=function(msg) {this.ws.send(msg);} } var ws; $(document).ready(function(){ ws=new WebSocketAdapter("ws://localhost:8080/"); }); </script> </head> <body> <form> Enviar al servidor: <input id="texto" type="text" value="hola mundo!"></input> <input id="enviar" type="button" value="enviar" onclick="ws.send($('#texto').val())"/> </form> <div id="msg"></div> </body> </html>
  • 32. Nuestro cliente<html> <head> <script src='jquery.min.js'></script> <script> function WebSocketAdapter(url){ this.ws=new WebSocket(url); this.ws.onmessage = function(evt) {$("#msg").append("<p>"+evt.data+"</p>");}; this.ws.onclose = function() { alert("socket cerrado"); }; this.ws.onopen = function() { alert("conectado..."); }; this.send=function(msg) {this.ws.send(msg);} } var ws; $(document).ready(function(){ ws=new WebSocketAdapter("ws://localhost:8080/"); }); </script> </head> <body> <form> Enviar al servidor: <input id="texto" type="text" value="hola mundo!"></input> <input id="enviar" type="button" value="enviar" onclick="ws.send($('#texto').val())"/> </form> <div id="msg"></div> </body> </html>
  • 33. Nuestro cliente<html> <head> <script src='jquery.min.js'></script> <script> function WebSocketAdapter(url){ this.ws=new WebSocket(url); this.ws.onmessage = function(evt) {$("#msg").append("<p>"+evt.data+"</p>");}; this.ws.onclose = function() { alert("socket cerrado"); }; this.ws.onopen = function() { alert("conectado..."); }; this.send=function(msg) {this.ws.send(msg);} } var ws; $(document).ready(function(){ ws=new WebSocketAdapter("ws://localhost:8080/"); }); </script> </head> <body> <form> Enviar al servidor: <input id="texto" type="text" value="hola mundo!"></input> <input id="enviar" type="button" value="enviar" onclick="ws.send($('#texto').val())"/> </form> <div id="msg"></div> </body> </html>
  • 34. Nuestro cliente<html> <head> <script src='jquery.min.js'></script> <script> function WebSocketAdapter(url){ this.ws=new WebSocket(url); this.ws.onmessage = function(evt) {$("#msg").append("<p>"+evt.data+"</p>");}; this.ws.onclose = function() { alert("socket cerrado"); }; this.ws.onopen = function() { alert("conectado..."); }; this.send=function(msg) {this.ws.send(msg);} } var ws; $(document).ready(function(){ ws=new WebSocketAdapter("ws://localhost:8080/"); }); </script> </head> <body> <form> Enviar al servidor: <input id="texto" type="text" value="hola mundo!"></input> <input id="enviar" type="button" value="enviar" onclick="ws.send($('#texto').val())"/> </form> <div id="msg"></div> </body> </html>
  • 35. Nuestro cliente<html> <head> <script src='jquery.min.js'></script> <script> function WebSocketAdapter(url){ this.ws=new WebSocket(url); this.ws.onmessage = function(evt) {$("#msg").append("<p>"+evt.data+"</p>");}; this.ws.onclose = function() { alert("socket cerrado"); }; this.ws.onopen = function() { alert("conectado..."); }; this.send=function(msg) {this.ws.send(msg);} } var ws; $(document).ready(function(){ ws=new WebSocketAdapter("ws://localhost:8080/"); }); </script> </head> <body> <form> Enviar al servidor: <input id="texto" type="text" value="hola mundo!"></input> <input id="enviar" type="button" value="enviar" onclick="ws.send($('#texto').val())"/> </form> <div id="msg"></div> </body> </html>
  • 36. Nuestro cliente<html> <head> <script src='jquery.min.js'></script> <script> function WebSocketAdapter(url){ this.ws=new WebSocket(url); this.ws.onmessage = function(evt) {$("#msg").append("<p>"+evt.data+"</p>");}; this.ws.onclose = function() { alert("socket cerrado"); }; this.ws.onopen = function() { alert("conectado..."); }; this.send=function(msg) {this.ws.send(msg);} } var ws; $(document).ready(function(){ ws=new WebSocketAdapter("ws://localhost:8080/"); }); </script> </head> <body> <form> Enviar al servidor: <input id="texto" type="text" value="hola mundo!"></input> <input id="enviar" type="button" value="enviar" onclick="ws.send($('#texto').val())"/> </form> <div id="msg"></div> </body> </html>
  • 37. Nuestro cliente<html> <head> <script src='jquery.min.js'></script> <script> function WebSocketAdapter(url){ this.ws=new WebSocket(url); this.ws.onmessage = function(evt) {$("#msg").append("<p>"+evt.data+"</p>");}; this.ws.onclose = function() { alert("socket cerrado"); }; this.ws.onopen = function() { alert("conectado..."); }; this.send=function(msg) {this.ws.send(msg);} } var ws; $(document).ready(function(){ ws=new WebSocketAdapter("ws://localhost:8080/"); }); </script> </head> <body> <form> Enviar al servidor: <input id="texto" type="text" value="hola mundo!"></input> <input id="enviar" type="button" value="enviar" onclick="ws.send($('#texto').val())"/> </form> <div id="msg"></div> </body> </html>
  • 38. Echo (single client) require 'rubygems' require 'eventmachine-websocket' EventMachine::WebSocket.start(:host => "0.0.0.0", :port => 8080) do |con| con.on_open { con.send "Cliente conectado"} con.on_message { |msg| con.send msg.reverse } con.on_close { puts "Cliente desconectado" } end
  • 39. Multichat en 23LOC require 'rubygems' require 'eventmachine-websocket' connections=[] indexes={} EventMachine::WebSocket.start(:host => "0.0.0.0", :port => 8080) do |con| con.on_open do indexes[con]=connections.size+1 con.send "<p class="highlight">Eres el cliente #{indexes[con]}<p>" connections.each{ |c| c.send "<p class="highlight">El cliente #{indexes[con]} ha entrado en la sala<p>" } connections << con end con.on_message do |msg| connections.each{ |c| c.send "<p><span class="cliente">Cliente #{indexes[con]}:</span> #{msg}</p>" } end con.on_close do c.send "<p class="highlight">Has abandonado la sala</p>" connections.delete con indexes.delete con end end
  • 40.
  • 41. Conclusiones • Hasta la aparición de HTML5, XMPP tenía unas expectativas muy altas como alternativa a Comet. • Sin embargo, se han cancelado muchos servicios XMPP para el consumo de datos en tiempo real (Twitter firehose API) • Websocket se presenta como una alternativa más simple y elegante para la implementación de servicios Web de tiempo real • XMPP no pierde fuerza para mensajería instantánea
  • 44. CLOUD COMPUTING. DESARROLLO DE APLICACIONESY MINERÍA WEB Programa de extensión universitariaUniversidad de Oviedo Miguel Fernández Fernández miguel@ThirdWay.es