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

KRTConf: WebSockets & Sub-Protocols

miksago
November 11, 2011

KRTConf: WebSockets & Sub-Protocols

miksago

November 11, 2011
Tweet

More Decks by miksago

Other Decks in Programming

Transcript

  1. Micheil Smith - @miksago
    WebSockets &
    Sub-protocols

    View full-size slide

  2. I work at Pusher
    BUILDING THE REALTIME WEB

    View full-size slide

  3. ...and we think that
    WebSockets are
    awesome, but...

    View full-size slide

  4. ...they are too low
    level for most
    applications

    View full-size slide

  5. ...until we add
    extra meaning to
    them

    View full-size slide

  6. What are Sub-Protocols?
    • A definition of the data over a WebSocket
    Connection.
    • A way to negotiate communication
    between Client and Server.
    • A way to standardise what we’re already
    doing with WebSockets today.

    View full-size slide

  7. Common ways to use
    WebSockets
    • Events
    • Channels
    • Request / Response
    • Firehoses
    • Query / Filter Streams

    View full-size slide

  8. Events
    • Streams of data augmented with
    an “event-type”.
    • A form of Publish / Subscribe paradigm
    • Usually paired with Channels

    View full-size slide

  9. Channels
    • Groups data into named buckets
    • Usually combined with “Events”
    • Most common way to use WebSockets
    • Examples: Pusher, Socket.io

    View full-size slide

  10. Request / Response
    • Both Synchronous and Asynchronous
    • JSON-RPC over WS (1.0, 2.0)
    • SOAP over WS (Microsoft, Jan 2012)
    • REST over WS

    View full-size slide

  11. Firehoses
    • A stream of data, where each message is
    a single piece of information
    • Structure of data is dependent on source
    • Could be as simple as the Twitter firehose
    over WebSockets

    View full-size slide

  12. Query / Filter Streams
    • Used on Firehoses of data
    • Client registers query with server
    • As data matches a query, it is sent to the client
    • Example: PubSub.io

    View full-size slide

  13. Using Sub-Protocols
    • Defined in WSP Section 1.9
    • Uses header in handshake for negotiation
    of sub-protocol.
    • Clients tell server which sub-protocols it
    supports, server then selects one to use.
    • Sub-protocols can be registered with IANA
    (WSP Section 11.5)

    View full-size slide

  14. Only registered one is...
    • SOAP over WS... by Microsoft (they
    haven’t actually defined the protocol yet)

    View full-size slide

  15. Lets start defining
    the first generation
    of sub-protocols!

    View full-size slide

  16. A few sub-protocols we
    should define
    • JSON-RPC
    • Standardised Channels & Events
    • Query streams
    • Publish / Subscribe

    View full-size slide

  17. We’re Hiring!
    Systems Engineer
    - Ruby, C, Haskell, Erlang, etc
    Head of Operations
    - Puppet/Chef, Cloud Architecture, etc
    Mobile Developer
    - low level Objective-C, Java

    View full-size slide

  18. Thanks for listening!
    @miksago
    on
    Twitter / Github / Geekli.st

    View full-size slide