Este documento discute as tecnologias para aplicações web em tempo real, incluindo chat, feeds e chamadas API. Ele explica como essas abordagens evoluíram de soluções como multipart/x-mixed-replace e iframes para AJAX, JavaApplet, FlashSocket e WebSocket. Também discute como implementar aplicações em tempo real com Rails usando Faye e Sync para publicação e assinatura de eventos.
4. O que é
The real-time web is a set of technologies and pratices that
enable users to receive information as soon as it is published by
its authors, rather than requiring that they or their software
check a source periodicaly for updates.
5. O que fazer
● Chat
● Feeds
● Chamadas API
● Modo Colaborativo
6. Abordagens durante o tempo
● Abordagem da netscape
○ Content type: multipart/x-mixed-replace; boundary=separator
● IE e o Iframe
○ Connection: keep-alive
● AJAX Pooling e LongPooling
○ setInterval({ url: ‘/collection’, success: function(data){
//DoIT
}}, 5000);
● JavaApplet
● FlashSocket
● WebSocket
13. CRUD
E você levando 1h para criar uma
tela de cadastro ai...
cd /var/vagrant
rails g scaffold Person name:string
birthday:date age:integer
rake db:migrate
git add .
git commit -m ‘rails generate is
awesome!’
GET http://localhost:3000/persons
ops!
GET http://localhost:3000/people
16. Rodando o
servidor
Aquele que vai enviar as
notificações
vagrant ssh
cd /var/vagrant
# Added require sync in application.js
# Added Sync tag in application.html
rackup sync.ru -E prodution --host
0.0.0.0
17. Verificando o Faye
Antes de testar, verifica se não deu
problema!
GET http://localhost:9292/faye/faye.js
# Connect channel (client)
var client = new Faye.Client('http://localhost:9292/faye');
client.subscribe('/messages', function(message) {
alert('Got a message: ' + message.text);
});
# Send message
client.publish('/messages', {
text: 'Hello world'
});