• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
WebSockets: um upgrade de comunicação no HTML5
 

WebSockets: um upgrade de comunicação no HTML5

on

  • 1,278 views

Conheça a nova tecnologia WebSockets, e como utilizá-la em Java

Conheça a nova tecnologia WebSockets, e como utilizá-la em Java

Statistics

Views

Total Views
1,278
Views on SlideShare
1,268
Embed Views
10

Actions

Likes
2
Downloads
31
Comments
0

2 Embeds 10

https://twitter.com 9
http://eventifier.co 1

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    WebSockets: um upgrade de comunicação no HTML5 WebSockets: um upgrade de comunicação no HTML5 Presentation Transcript

    • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 132WebSockets: um upgradede comunicação no HTML5Bruno BorgesOracle Product ManagerJava Evangelist@brunoborges
    • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 133Bruno BorgesOracle Product Manager / EvangelistDesenvolvedor, GamerEntusiasta em Java Embedded eJavaFXTwitter: @brunoborges
    • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 134Java EE 7está pronto!
    • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 135Java EE 7 Escopo●Produtividade de Desenvolvimento– Menos código Boilerplate– Funcionalidades mais ricas– Mais convenções e defaults●Suporte a HTML5– WebSocket– JSON– HTML5 FormsJSR 342
    • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 136Java EE 7EJB 3.2Servlet 3.1CDIExtensionsBatch 1.0WebFragmentsJCA 1.7JMS 2.0JPA 2.1Managed Beans 1.0Concurrency 1.0CommonAnnotations 1.1Interceptors1.2, JTA 1.2CDI 1.1JSF 2.2,JSP 2.3,EL 3.0JAX-RS 2.0,JAX-WS 2.2JSON 1.0WebSocket 1.0
    • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 137Construindo aplicações HTML5com WebSockets Java API WebSocket 1.0 – JSR 356 RFC 6455 W3C Web Sockets API– JavaScript objects
    • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 138HTTP vs WebSockets Protocolo HTTP é half-duplex Gambiarras– Polling– Long polling– Streaming WebSocket resolve o problemade uma vez por todas– Full-duplex
    • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 139WebSockets Handshake Cliente solicita um UPGRADE Server confirma (Servlet 3.1) Cliente recebe o OK Inicia a sessão WebSockethttp://farata.github.io/slidedecks/state_of_websocket/slides.html#13.4
    • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1310WebSockets API for Javascriptvar ws;if (window.WebSocket) {ws = new WebSocket("ws://echo.websocket.org");ws.onopen = function () {console.log("onopen");};ws.onmessage = function (e) {// e.data contains received string.console.log("echo from server : " + e.data);};ws.onclose = function () { console.log("onclose"); };ws.onerror = function () { console.log("onerror"); };} else {console.log("WebSocket not supported in your browser");}if (ws.readyState === 1) ws.send("Hello WebSocket!");
    • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1311WebSockets Facts WS não funciona por proxies Suporte incompleto em browsers Desafios de configurar WebSocket com LBRs
    • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1312WebSockets e Browsers
    • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1313WebSockets só roda em navegadores Web?
    • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1314Clientes além de Navegadores iOS– SocketRocket Android– Async HTTP Client– AutobahnAndroid Java libs and JavaFX– WebView HTML5 component
    • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1315Ping Pong Serve para manter a conexão ativa Programaticamente possível interceptar– Server– Client
    • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1316Java API for WebSockets 1.0 API para definir WebSockets, tanto Client como Server– Annotation-driven (@ServerEndpoint)– Interface-driven (Endpoint)– Client (@ClientEndpoint) SPI para data frames– Negociação handshake na abertura do WebSocket Integração com o Java EE Web container
    • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1317Java API for WebSockets 1.0import javax.websocket.*;import javax.websocket.server.*;@ServerEndpoint(“/hello”)public class HelloBean {    @OnMessage    public String sayHello(String name) {        return “Hello “ + name;    }}
    • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1318Java API for WebSockets 1.0@ServerEndpoint(“/chat”)public class ChatBean {    @OnOpen    public void onOpen(Session peer) {        peers.add(peer);    }    @OnClose    public void onClose(Session peer) {        peers.remove(peer);    }    @OnMessage    public void message(String msg, Session client) {        peers.forEach(p ­> p.getRemote().sendMessage(msg));    }}
    • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1319DEMOWebSockets
    • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1320Casos de Uso para WebSockets Placar de jogos Controlar equipamentos pela Web Chat MMORPG Atualização de Social Streams em tempo real Ferramentas em geral com auto refresh
    • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1321Perguntas?
    • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1322Créditos: Fara Systems Conteúdo de WebSockets extraído de:farata.github.io/slidedecks/state_of_websocket/slides.html#1.0
    • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1323OBRIGADO!@brunoborgesblogs.oracle.com/brunoborges
    • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1324The preceding is intended to outline our general product direction. It is intendedfor information purposes only, and may not be incorporated into any contract.It is not a commitment to deliver any material, code, or functionality, and shouldnot be relied upon in making purchasing decisions. The development, release,and timing of any features or functionality described for Oracle’s productsremains at the sole discretion of Oracle.
    • Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 1325