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

Realtime APIs using WebSockets in PHP

Realtime APIs using WebSockets in PHP

Porque Web Socket se tornou a melhor proposta para substituir as requisições AJAX, Comet, Streaming (para dados) e similares.
Como implementar um WSServer usando Ratchet

Ricardo Coelho

November 29, 2013
Tweet

More Decks by Ricardo Coelho

Other Decks in Programming

Transcript

  1. Real Time APIs
    using WebSockets in PHP
    @ramcoelho

    View Slide

  2. Why WebSockets?

    View Slide

  3. Why WebSockets?
    HTML
    CSS
    Javascript
    HTML
    CSS
    Javascript

    View Slide

  4. What about AJAX?
    What about Comet?
    What about Streaming?

    View Slide

  5. WS is TCP for Browsers
    Full Duplex
    Connection Oriented
    but better…
    Text AND Binary
    Message Boundaries
    URL Addressing

    View Slide

  6. How do I implement?

    View Slide

  7. API and Protocol

    View Slide

  8. API and Protocol
    onOpen
    onMessage
    onClose
    onError
    Piece of cake!
    Handshaking
    Key Negotiating
    Frame vs. Message
    Versioning
    Extensions
    Message Format
    Fragmentation
    Masking
    Keep Alive
    Error Handling
    Wrapped Protocols
    Think again

    View Slide

  9. API and Protocol
    Ratchet

    View Slide

  10. socketo.me/docs/hello-world

    View Slide

  11. Installing Ratchet
    youtu.be/7jLwFeKAyXE

    View Slide

  12. Mandatory Methods
    youtu.be/7jLwFeKAyXE

    View Slide

  13. The Listener
    youtu.be/7jLwFeKAyXE

    View Slide

  14. Message Handlers
    youtu.be/7jLwFeKAyXE

    View Slide

  15. Test via Regular Sockets
    youtu.be/7jLwFeKAyXE

    View Slide

  16. Testing via Javascript
    youtu.be/7jLwFeKAyXE

    View Slide

  17. Thank You!

    View Slide