Copyright | (c) 2016 Michael Walker |
---|---|
License | MIT |
Maintainer | Michael Walker <mike@barrucadu.co.uk> |
Stability | experimental |
Portability | GeneralizedNewtypeDeriving, ScopedTypeVariables |
Safe Haskell | None |
Language | Haskell2010 |
Internal types and functions. This is NOT considered to form part of the public API of this library.
- newtype PusherClient a = PusherClient (ReaderT Pusher IO a)
- runPusherClient :: Pusher -> PusherClient a -> IO a
- data Pusher = Pusher {
- commandQueue :: TQueue PusherCommand
- connState :: TVar ConnectionState
- options :: Options
- idleTimer :: TVar (Maybe Int)
- lastReceived :: TVar UTCTime
- socketId :: TVar (Maybe Text)
- threadStore :: TVar (Set ThreadId)
- eventHandlers :: TVar (HashMap Binding Handler)
- nextBinding :: TVar Binding
- allChannels :: TVar (Set Channel)
- presenceChannels :: TVar (HashMap Channel (Value, HashMap Text Value))
- data PusherCommand
- data TerminatePusher = TerminatePusher (Maybe Word16)
- data PusherClosed = PusherClosed (Maybe Word16)
- data ConnectionState
- defaultPusher :: Options -> IO Pusher
- sendCommand :: Pusher -> PusherCommand -> IO ()
- data Options = Options {}
- data Cluster
- newtype AppKey = AppKey String
- defaultOptions :: AppKey -> Options
- data Handler = Handler (Maybe Text) (Maybe Channel) (Value -> PusherClient ())
- newtype Channel = Channel {}
- newtype Binding = Binding {}
- ask :: PusherClient Pusher
- strictModifyTVar :: NFData a => TVar a -> (a -> a) -> STM ()
- strictModifyTVarIO :: (MonadIO m, NFData a) => TVar a -> (a -> a) -> m ()
- readTVarIO :: MonadIO m => TVar a -> m a
- ignoreAll :: a -> IO a -> IO a
- reconnecting :: IO a -> IO () -> IO a
- catchNetException :: forall a. IO a -> (SomeException -> IO a) -> IO a
- catchAll :: IO a -> (SomeException -> IO a) -> IO a
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.
PusherClient (ReaderT Pusher IO a) |
runPusherClient :: Pusher -> PusherClient a -> IO a Source #
Run a PusherClient
.
Pusher connection handle.
If this is used after disconnecting, an exception will be thrown.
Pusher | |
|
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
|
Terminate | Gracefully close the connection. |
data TerminatePusher Source #
An exception thrown to kill the client.
data PusherClosed Source #
Thrown if attempting to communicate with Pusher after the connection has been closed.
If the server closed the connection, the error code is included. See the 4000-4099 error codes on https://pusher.com/docs/pusher_protocol.
data ConnectionState Source #
The state of the connection. Events are sent when the state is changed.
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 |
Connected | The connection is established and authenticated with your app. Emits the |
Unavailable | The connection is temporarily unavailable. The network connection is down, the server is down, or something is blocking the connection. Emits the |
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 |
sendCommand :: Pusher -> PusherCommand -> IO () Source #
Send a command to the queue. Throw a PusherClosed
exception if
the connection has been disconnected.
Options | |
|
Clusters correspond to geographical regions where apps can be assigned to.
Your application's API key.
Event handlers: event name -> channel name -> handler.
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.
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.
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
.
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.