O documento apresenta conceitos e técnicas de push technology, incluindo polling, long polling, server-sent events, forever frames e web sockets. Apresenta também o framework SignalR da Microsoft para implementar comunicação em tempo real entre clientes e servidor.
2. Bio
Walter Dias
SI & EAS
Localiza Rent a Car
Video Game Whore
G33K
Level 26
Arquiteto Software
Tecnologias Microsoft
walterbh@gmail.com
@walterbh
bit.ly/1721Szi
21. Server Sent Events - JS
if (!window.EventSource) {
alert("Seu browser é o M$IE");
}
var source = new EventSource('stream.asp');
source.addEventListener('message', function (e) {
//do something
}, false);
source.addEventListener('open', function (e) {
// connection was opened.
}, false);
source.addEventListener('error', function (e) {
if (e.readyState == EventSource.CLOSED) {
// connection was closed.
}
}, false);
22. Server Sent Events - Server
Content-Type: text/event-stream
data:
data:
data:
data:
{n
"msg": "hello world",n
"id": 12345n
}nn
data, event, id, retry