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

Full-duplex cloud app with WebSocket

Full-duplex cloud app with WebSocket

Slide from my talk "Full-duplex cloud app with WebSocket" at pragma conference 2013(http://pragmamark.org/eventi/pragma-conference-2013/#speakers_hook) about how to create iOS app that communicate in full-duplex way with the cloud (using WebSocket and socket.io)

Code: https://github.com/lukabernardi/RealtimeLocation

Luca Bernardi

October 29, 2013
Tweet

More Decks by Luca Bernardi

Other Decks in Technology

Transcript

  1. Full-duplex cloud app
    with WebSocket

    View Slide

  2. @luka_bernardi
    Luca Bernardi

    View Slide

  3. “Everything goes
    through an API, 

    we are functioning 

    with cloud app”
    “Mobile is not Different” https://vimeo.com/61044805

    View Slide

  4. Document vs. Stream
    Paradigms

    View Slide

  5. Document Paradigm
    Built around request/response 

    paradigm of HTTP

    View Slide

  6. Stream Paradigm
    Instantly update your content as things happens

    View Slide

  7. What we are going to build

    View Slide

  8. Hey, what about old
    good BSD socket?

    View Slide

  9. “No App is an island”
    Not suitable for web applications

    View Slide

  10. Abstraction
    Wouldn’t be nice to have an 

    event-based layer of abstraction?

    View Slide

  11. Abusing HTTP
    Polling
    Long Polling
    Streaming

    View Slide

  12. Meet WebSocket
    !
    Independent TCP-based protocol that enables
    bidirectional, message-oriented streaming of text
    and binary data between client and server.

    View Slide

  13. Server side
    [JS/Node.js] Socket.io (http://socket.io)
    [Python] Tornado (http://
    www.tornadoweb.org)
    [Ruby] em-websocket (https://
    github.com/igrigorik/em-websocket)
    [Objective-C] RockemSockem (https://
    github.com/joshaber/RockemSockem)
    http://www.pusher.com
    http://www.pubnub.com
    https://www.hydna.com
    Comprehensive of realtime web technologies: https://github.com/leggetter/realtime-web-technologies-guide/blob/master/guide.md
    Self-Hosted Hosted

    View Slide

  14. Socket.io
    Socket.io > WebSocket
    Abstract the transport mechanism

    View Slide

  15. Event/Message based

    View Slide

  16. Heartbeat
    By sending a heartbeat at a predetermined
    interval the client informs the server 

    that it's still there.

    View Slide

  17. Rooms
    Partitioning of the connected clients.

    View Slide

  18. Show us some code!

    View Slide

  19. Server Code

    View Slide

  20. Client libraries
    AZSocketIO (https://github.com/pashields/AZSocketIO)
    Socket.IO-objc (https://github.com/pkyeck/socket.IO-objc)

    View Slide

  21. Client Code

    View Slide

  22. Use Case
    Chat / Messaging
    Real-time geolocation
    Stream of event/news
    Real-time collaboration
    Games

    View Slide

  23. Think different
    your API
    Photo by Héctor García (http://www.flickr.com/photos/torek/7109339349/)

    View Slide

  24. Question?

    View Slide