pusher-ws- Implementation of the Pusher WebSocket protocol

Copyright(c) 2016 Michael Walker
MaintainerMichael Walker <mike@barrucadu.co.uk>
PortabilityGeneralizedNewtypeDeriving, ScopedTypeVariables
Safe HaskellNone



Internal types and functions. This is NOT considered to form part of the public API of this library.



newtype PusherClient a Source #

A value of type PusherClient a is a computation with access to a connection to Pusher which, when executed, may perform Pusher-specific actions such as subscribing to channels and receiving events, as well as arbitrary I/O.


PusherClient (ReaderT Pusher IO a) 

data Pusher Source #

Pusher connection handle.

If this is used after disconnecting, an exception will be thrown.




data PusherCommand Source #

A command to the Pusher thread.


SendMessage Value

Send a message over the network, not triggering event handlers.

SendLocalMessage Value

Do not send a message over the network, trigger event handlers.

Subscribe Channel Value

Send a channel subscription message and add to the allChannels set.


Gracefully close the connection.

data ConnectionState Source #

The state of the connection. Events are sent when the state is changed.



Initial state. No event is emitted.


Trying to connect. This state will also be entered when trying to reconnect after a connection failure.

Emits the "connecting" event.


The connection is established and authenticated with your app.

Emits the "connected" event.


The connection is temporarily unavailable. The network connection is down, the server is down, or something is blocking the connection.

Emits the "unavailable" event and then enters the Connecting state again.

Disconnected (Maybe Word16)

The connection has been closed by the client, or the server indicated an error which cannot be resolved by reconnecting with the same settings.

If the server closed the connection, the error code is included. See the 4000-4099 error codes on https://pusher.com/docs/pusher_protocol.

Emits the "disconnected" event and then kills all forked threads.

defaultPusher :: Options -> IO Pusher Source #

State for a brand new connection.

sendCommand :: Pusher -> PusherCommand -> IO () Source #

Send a command to the queue. Throw a PusherClosed exception if the connection has been disconnected.

data Options Source #




  • appKey :: AppKey

    The application key.

  • encrypted :: Bool

    If the connection should be made over an encrypted connection. Defaults to True.

  • authorisationURL :: Maybe String

    The URL which will return the authentication signature needed for private and presence channels. If not given, private and presence channels cannot be used. Defaults to Nothing.

  • cluster :: Cluster

    Allows connecting to a different cluster by setting up correct hostnames for the connection. This parameter is mandatory when the app is created in a different cluster to the default us-east-1. Defaults to MT1.

  • pusherURL :: Maybe (HostName, PortNumber, String)

    The host, port, and path to use instead of the standard Pusher servers. If set, the cluster is ignored. Defaults to Nothing.

data Cluster Source #

Clusters correspond to geographical regions where apps can be assigned to.



The us-east-1 cluster.


The eu-west-1 cluster.


The ap-southeast-1 cluster.

defaultOptions :: AppKey -> Options Source #

See Options field documentation for what is set here.

data Handler Source #

Event handlers: event name -> channel name -> handler.


Handler (Maybe Text) (Maybe Channel) (Value -> PusherClient ()) 


NFData Handler Source # 


rnf :: Handler -> () #

newtype Channel Source #

Channel handle: a witness that we joined a channel, and is used to subscribe to events.

If this is used when unsubscribed from a channel, nothing will happen.




newtype Binding Source #

Event binding handle: a witness that we bound an event handler, and is used to unbind it.

If this is used after unbinding, nothing will happen.




ask :: PusherClient Pusher Source #

Get the current state.

strictModifyTVar :: NFData a => TVar a -> (a -> a) -> STM () Source #

Modify a TVar strictly.

strictModifyTVarIO :: (MonadIO m, NFData a) => TVar a -> (a -> a) -> m () Source #

Modify a TVar strictly in any MonadIO.

readTVarIO :: MonadIO m => TVar a -> m a Source #

Read a TVar inside any MonadIO.

ignoreAll :: a -> IO a -> IO a Source #

Ignore all exceptions by supplying a default value.

reconnecting :: IO a -> IO () -> IO a Source #

Run an action, starting again on connection and handshake exception.

catchNetException :: forall a. IO a -> (SomeException -> IO a) -> IO a Source #

Catch all network exceptions.

catchAll :: IO a -> (SomeException -> IO a) -> IO a Source #

Catch all exceptions.