Coder Social home page Coder Social logo

pusher-ws's Introduction

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 ([email protected]).

pusher-ws's People

Contributors

barrucadu avatar hacxman avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.