15. Prós
Sem atraso nas respostas
Múltiplos requests
Contras
Baixa carga no servidor
Existem técnicas mais rápidas
Suportado por vários Browsers
16.
17. Prós
Suportado por vários Browsers
Contras
Contras Problemas com peculiaridades de
cada Browser.
Muito difícil de tratar os erros
18.
19. Prós
Conexão persistente.
Não necessidta de um protocolo especial
implementado no servidor.
Contras
Nâo é suportado pelo Internet Explorer.
Trabalha apenas na direção:
Server > Client.
20.
21. Prós
Conexão persistente nas duas direções.
Melhor performance.
Contras
Requer protocolo WEB SOCKET IE 10 e demais
browsers (versões atualizadas)
Requer protocolo WEB SOCKET no Servidor (IIS8)
28. Aplicação .NET (Server Side)
HUB API
API de Conexão Persistente
Transportes
HTML5 Comet
Web Sockets
Server Sent Events
Forever Frame
Ajax Long Polling
Browser (Client Side)
HUB API
API de Conexão Persistente
Transportes
Browser (Client Side)
HUB API
API de Conexão Persistente
Transportes
Browser (Client Side)
HUB API
API de Conexão Persistente
Transportes
Servidor
Clientes
35. PUBLIC CLASS SHAPEHUB : HUB
{
//
// RECEBE MENSAGENS DO CLIENTE
//
PUBLIC VOID MOVESHAPE(INT X, INT Y)
{
//
// ENVIA MENSAGENS PARA O CLIENTE
//
THIS.CLIENTS.OTHERS.UPDATESHAPE(X, Y);
}
}
Simples definição do Hub
Implementação dos
métodos
Uso intensivo de Anonymous
Methods
36. <SCRIPT TYPE="TEXT/JAVASCRIPT">
$(FUNCTION () {
VAR SHAPE = $("#SHAPE");
$.CONNECTION.HUB.START().DONE(FUNCTION () {
SHAPE.DRAGGABLE({
DRAG: FUNCTION () {
// ENVIA A NOVA POSIÇÃO PARA O SERVIDOR
$.CONNECTION.SHAPEHUB.SERVER.MOVESHAPE(
SHAPE.POSITION().LEFT,
SHAPE.POSITION().TOP);
}
});
});
// RECEBE AS MENSAGENS DO SERVIDOR
$.CONNECTION.SHAPEHUB.CLIENT.UPDATESHAPE = FUNCTION (X, Y) {
SHAPE.ANIMATE({ LEFT: X, TOP: Y }, { QUEUE: FALSE });
}
});
</SCRIPT>
Implementação dos
métodos no cliente “.client”
Pode chamar métodos no
servidor “.server”
46. MANTENHA CONTATO NO WWW.100LOOP.COM
ANDRÉ PAULOVICH PAULOVICH@100LOOP.COM
IVAN PAULOVICH - IVAN@100LOOP.COM
Notas do Editor
Regular http:A client requests a webpage from a server.The server calculates the responseThe server sends the response to the client.Referência:http://stackoverflow.com/questions/11077857/what-are-long-polling-websockets-server-sent-events-sse-and-comet
AJAX Polling:A client requests a webpage from a server using regular http (see http above).The requested webpage executes javascript which requests a file from the server at regular intervals (e.g. 0.5 seconds).The server calculates each response and sends it back, just like normal http traffic.
AJAX Long-Polling:A client requests a webpage from a server using regular http (see http above).The requested webpage executes javascript which requests a file from the server.The server does not immediately respond with the requested information but waits until there's new information available.When there's new information available, the server responds with the new information.The client receives the new information and immediately sends another request to the server, re-starting the process.
HTML5 Server Sent Events (SSE) / EventSource:A client requests a webpage from a server using regular http (see http above).The requested webpage executes javascript which opens a connection to the server.The server sends an event to the client when there's new information available.real-time traffic from server to client, mostly that's what you'll needyou'll want to use a server that has an event loopnot possible to connect with a server from another domainIf you want to read more, I found thse (article), (article), (article), (tutorial) very useful.
HTML5 Server Sent Events (SSE) / EventSource:A client requests a webpage from a server using regular http (see http above).The requested webpage executes javascript which opens a connection to the server.The server sends an event to the client when there's new information available.real-time traffic from server to client, mostly that's what you'll needyou'll want to use a server that has an event loopnot possible to connect with a server from another domainIf you want to read more, I found thse (article), (article), (article), (tutorial) very useful.
HTML5 Websockets:A client requests a webpage from a server using regular http (see http above).The requested webpage executes javascript which opens a connection with the server.The server and the client can now send each other messages when new data (on either side) is available.real-time traffic from the server to the client and from the client to the serveryou'll want to use a server that has an event loopwith WebSockets it is possible to connect with a server from another domain.It is also possible to use a third party hosted websocket server, for example Pusher or others. This way you'll only have to implement the client side, which is very easy!If you want to read more, I found thse (article), (article) (tutorial) very useful.