Upgrade to Pro — share decks privately, control downloads, hide ads and more …

WebSockets (sflive2012)

WebSockets (sflive2012)

A4b95be2145cc46f891707b6db9dd82d?s=128

Igor Wiedler

June 08, 2012
Tweet

Transcript

  1. WEBSOCKETS

  2. • Symfony2 • Silex • Composer igorw @igorwesome

  3. WEBSOCKETS

  4. WEB

  5. Application HTTP Presentation TCP Session TCP Transport TCP Network IP

    Data Link Physical
  6. Application HTTP Presentation TCP Session TCP Transport TCP Network IP

    Data Link Physical
  7. client

  8. request client

  9. reponse client request

  10. THIS IS A GOOD THING

  11. BUT

  12. NOT FOR EVERYTHING

  13. UNIDIRECTIONAL

  14. None
  15. LATENCY

  16. LATENCY KEEP-ALIVE PIPELINING SPDY

  17. STATELESS

  18. Application HTTP Presentation TCP Session TCP Transport TCP Network IP

    Data Link Physical
  19. Application HTTP Presentation TCP Session TCP Transport TCP Network IP

    Data Link Physical
  20. WEBSOCKETS

  21. SOCKETS

  22. WEBSOCKETS

  23. PROTOCOL API

  24. THE WEBSOCKET PROTOCOL

  25. browser

  26. None
  27. • Handshake / Upgrade • TCP + framing • Proxies

    • Supports TLS (SSL)
  28. RFC 6455

  29. THE WEBSOCKET API

  30. browser

  31. var ws = new WebSocket('ws://example.org:8080/updates'); ws.onopen = function () {

    ws.send('hello'); }; ws.onmessage = function (event) { console.log(event.data); };
  32. USE CASES •Games •Notifications •Collaboration •Statistics •Chat

  33. 4.0+ (2009) 6.0+ (2011) 10.70+ (2012) 5.0+ (2010) 10+ (2012)

  34. • transport abstraction (fallbacks) • broadcasting, reconnection, serialization, other stuff

    • monolithic! (and almost trying to fix it)
  35. SOCKJS

  36. var ws = new WebSocket(url);

  37. var ws = new SockJS(url);

  38. ASYNC STACK Connect Express SockJS

  39. ASYNC STACK ? ? SockJS

  40. ASYNC STACK EventMachine ? ? SockJS

  41. ASYNC STACK ? ? SockJS

  42. Y U NO PHP?

  43. SYNC STACK Application

  44. ASYNC Connect Express SockJS SYNC Application

  45. None
  46. None
  47. *MQ

  48. *MQ Sync Async

  49. DEMO

  50. DEBUGGING •printf •chrome inspector •wssh •ngrep •zmqc

  51. RECAP • Use SockJS • Polyglot is the future •

    Learn from the MQs
  52. LINKS • tools.ietf.org/html/rfc6455 • dev.w3.org/html5/websockets • sockjs.org

  53. github.com/igorw/websockets-talk

  54. CREDITS • thenounproject.com • stopwatch

  55. None
  56. None
  57. nodephp.org github.com/cboden/Ratchet

  58. Questions? @igorwesome speakerdeck.com /u/igorw joind.in/6586