This repository has been archived by the owner. It is now read-only.
Implementation of the Pusher WebSocket protocol in Haskell
Haskell
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Network/Pusher
.gitignore
LICENSE
README.markdown
Setup.hs
pusher-ws.cabal
stack.yaml

README.markdown

pusher-ws

An implementation of the Pusher WebSocket (client) protocol in Haskell.

Current features:

  • ws:// and wss:// protocols.
  • Clusters.
  • Subscribing to channels.
  • Unsubscribing from channels.
  • Authorisation for private and presence channels.
  • Binding event handlers.
  • Unbinding event handlers
  • Sending client events.
  • Threads which automatically get cleaned up on connection close.
  • Automatic reconnection (and channel resubscription).
  • Connection state events.
  • Pusher close codes.

Missing features:

  • "connecting_in" events.

The documentation of the latest developmental version is available online.

Example

Here's a tiny example to subscribe to a bunch of channels and just print out the messages received:

let key = "your-key"
let channels = ["your", "channels"]

-- Connect to Pusher with your key, SSL, and the us-east-1 region, and
-- do some stuff.
pusherWithOptions (defaultOptions key) $ do
  -- Subscribe to all the channels
  mapM_ subscribe channels

  -- Bind an event handler for all events on all channels which prints
  -- the received JSON.
  bindAll Nothing (liftIO . print)

  -- Wait for user input and then close the connection.
  liftIO (void getLine)
  disconnectBlocking

Contributing

Bug reports, pull requests, and comments are very welcome!

Feel free to contact me on GitHub, through IRC (#haskell on freenode), or email (mike@barrucadu.co.uk).