pusher-ws-0.1.1.0: Implementation of the Pusher WebSocket protocol

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

Network.Pusher.WebSockets.Internal

Description

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

Synopsis

Documentation

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.

Constructors

PusherClient (ReaderT Pusher IO a) 

data Pusher Source #

Pusher connection handle.

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

Constructors

Pusher 

Fields

data PusherCommand Source #

A command to the Pusher thread.

Constructors

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.

Terminate

Gracefully close the connection.

data ConnectionState Source #

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

Constructors

Initialized

Initial state. No event is emitted.

Connecting

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

Emits the "connecting" event.

Connected

The connection is established and authenticated with your app.

Emits the "connected" event.

Unavailable

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 #

Constructors

Options 

Fields

  • 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.

Constructors

MT1

The us-east-1 cluster.

EU

The eu-west-1 cluster.

AP1

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.

Constructors

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

Instances

NFData Handler Source # 

Methods

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.

Constructors

Channel 

Fields

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.

Constructors

Binding 

Fields

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.