1 / 11

Brewing Web Sockets

Brewing Web Sockets. Barista: Eduardo Moranchel. Java EE 7. Web Sockets vendrán incluidos en Java EE 7! EE 7 incluye Nuevo: WebSocket , JSON processing, Batch Appplications , Concurrency Utils . Grandes mejoras en:

viveca
Download Presentation

Brewing Web Sockets

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Brewing Web Sockets Barista: Eduardo Moranchel

  2. Java EE 7 • Web Sockets vendránincluidos en Java EE 7! • EE 7 incluye Nuevo: • WebSocket, JSON processing, Batch Appplications, Concurrency Utils. • Grandesmejoras en: • Expression Language 3.0 (lambda) JAX-RS2.0 (REST clients), JMS 2.0 (más sencillo) • Y mejoras en los API’s existentes. • JSF 2.2 (HTML5), Servlet 3.1, JSP 2.2, CDI 1.1, EJB 3.2, ETC.

  3. WebSockets. • Parte de la iniciativa de HTML 5 • Permiten comunicación bidireccional de baja latencia • Canal de comunicación abierto entre clientes y servidores. • API de JavaScript para navegadores modernos. • API en servidores (Java EE 7)

  4. ¿Por que WebSockets? • Extender HTTP para soportar conexiones bidireccionales! • Dar una solución al server push • Dar una solución al streaming (bidireccional) • Reemplazar AJAX y Comet?

  5. WebSockets y Ajax • WebSocketsNO es un reemplazo de AJAX o Comet • Es un complemento. • WebSocket soluciona problemas que antes se solucionaban con simulaciones (longpolling, response streaming) y amplia en capacidades de comunicación.

  6. Como funcionan? • Cliente pide conectarse a una URL usando el protocolo wso wss usando encabezados y tramas de HTTP • ws://localhost:80/websocket • Servidor responde con un código 101 de respuesta. • PERO deja la conexión abierta esperando y mandando mensajes en cualquier momento. • Si pasa mucho tiempo de inactividad se mandanmensajes de ping y pong.

  7. Show me code! • Para hacer un buen WebSocket en... • JavaScript: • Var websocket = new WebSocket(URI); • websocket.onmessage = function(event){};

  8. Show me morecode • WebSocket Servers en Java EE 7. • import javax.websocket.OnMessage; • import javax.websocket.server.ServerEndpoint; • @ServerEndpoint("/webSocketURL") • public class SampleWebSocket { • @OnMessage • public String onMessage(String message) { • return message; • } • }

  9. Letsbrewsomewebsockets • Vamos a desarrollar un chat. • Ingredientes: • GlassFish 4, NetBeans, HTML, JavaScript, Java. • Instrucciones: • Instalar y ejecutar glassfish 4 y NetBeans-dev. • Crear vista en HTML 5 • Crear Servidor Java EE 7 con WebSockets. • PROFIT

  10. More. • Usar Encoders y Decoders para manejar mas información en mensajes. • Usar CDI y CDI Events. • Tutoriales para WebSockets disponibles en un futuro (cercano) en Oracle Learning Library: • http://apex.oracle.com/pls/apex/f?p=44785:1 • Lanzamiento Java EE 7: ~Junio2013 aprox.

  11. Mas Información: • WebSockets: • http://www.websocket.org/ • WebSocket JSR • http://www.jcp.org/en/jsr/detail?id=356 • WebSocket API • http://dev.w3.org/html5/websockets/ • WebSocketProtocol • http://datatracker.ietf.org/doc/rfc6455/?include_text=1

More Related