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

Using slanger and websockets to power a warehouse backend

Using slanger and websockets to power a warehouse backend

Websockets are fun for chats and online games. But are there serious uses? ...

schokomarie

August 18, 2012
Tweet

Other Decks in Technology

Transcript

  1. $whoami
    Samstag, 18. August 2012

    View full-size slide

  2. Using slanger and
    websockets to power a
    warehouse backend
    Samstag, 18. August 2012

    View full-size slide

  3. © NBC
    Samstag, 18. August 2012

    View full-size slide

  4. What?
    •a web application for a
    printing company to simplify
    the packing process
    Samstag, 18. August 2012

    View full-size slide

  5. What?
    •the system runs on a touchscreen
    desktop in kiosk mode and needs to be
    synchronized in realtime
    Samstag, 18. August 2012

    View full-size slide

  6. © NBC
    Samstag, 18. August 2012

    View full-size slide

  7. websockets
    •native browser support
    •real bi-directional connection
    •less overhead than ajax-requests
    •easier to handle than long-polling
    Samstag, 18. August 2012

    View full-size slide

  8. © NBC
    Samstag, 18. August 2012

    View full-size slide

  9. protocol
    •roll your own
    •pre-made
    Samstag, 18. August 2012

    View full-size slide

  10. pusher
    •a webservice sending
    realtime messages
    between clients
    •german Datenschutz:
    can not send german client data to an
    us-based service
    Samstag, 18. August 2012

    View full-size slide

  11. © NBC
    Samstag, 18. August 2012

    View full-size slide

  12. slanger
    •open source websocket server
    •runs on a local machine
    •compatible with pusher‘s API
    •thus compatible with pusher. js
    Samstag, 18. August 2012

    View full-size slide

  13. architecture
    •Padrino backend
    •slanger
    •html-5 client
    Samstag, 18. August 2012

    View full-size slide

  14. architecture
    •application handles entity changes and
    sends events to slanger
    •client subscribes to slanger events
    •slanger dispatches events to the client
    •client uses event data to render
    mustache templates
    Samstag, 18. August 2012

    View full-size slide

  15. Samstag, 18. August 2012

    View full-size slide

  16. Samstag, 18. August 2012

    View full-size slide

  17. advantages
    •very simple client side js code
    •almost no logic in the client
    •server side business logic
    Samstag, 18. August 2012

    View full-size slide

  18. © NBC
    Samstag, 18. August 2012

    View full-size slide

  19. handle with care
    •Never mix client-side events with
    server-side events
    •keep all business logic on the server
    •Minimize assumptions about event
    behaviour in the client
    Samstag, 18. August 2012

    View full-size slide

  20. © NBC
    Samstag, 18. August 2012

    View full-size slide

  21. © NBC
    Samstag, 18. August 2012

    View full-size slide

  22. pitfalls
    •correct redis version (≥2.4.14)
    •slanger is an app, not a lib
    Samstag, 18. August 2012

    View full-size slide

  23. stuff
    • https://github.com/stevegraham/slanger
    • https://github.com/defunkt/resque
    • http://redis.io/
    • https://github.com/padrino/padrino-framework
    • http://handlebarsjs.com/
    • http://twitter.github.com/bootstrap/
    • http://www.websocket.org/quantum.html
    Samstag, 18. August 2012

    View full-size slide

  24. © NBC
    Samstag, 18. August 2012

    View full-size slide