Deadpan-DDP-0.8.0.0: Write clients for Meteor's DDP Protocol

Safe HaskellNone
LanguageHaskell2010

Web.DDP.Deadpan

Description

A collection of utilities to provide a way to create and run Deadpan apps.

This should be the only Deadpan module imported by users intending to use Deadpan as a library in order to write DDP applications.

Synopsis

Documentation

>>> import Control.Applicative
>>> import Test.QuickCheck

runBareClient :: Params -> DeadpanApp a -> IO a Source

Run a DeadpanApp against a set of connection parameters

Only runs the app. Does not send connection request. Does not respond to ping!

runConnectClient :: Params -> DeadpanApp a -> IO a Source

Run a DeadpanApp after establishing a server conncetion

Does not respond to ping!

runPingClient :: Params -> DeadpanApp a -> IO a Source

Run a DeadpanApp after registering a ping handler, then establishing a server conncetion.

runPingClientVersion :: Params -> Version -> DeadpanApp a -> IO a Source

Same as runPingClient above but allows specifying version

handlePings :: DeadpanApp GUID Source

Automatically respond to server pings

logEverything :: DeadpanApp (Chan String) Source

Log all incomming messages to STDOUT

Passes all messages through a Chan in order to not intermingle output lines.

Returns the chan so that it can be used by other sections of the app.

Alternatively just set LineBuffering on your output handle.

logEverythingVia :: DeadpanApp (Chan String) Source

A variant of log-everything returning a chan to recieve messages on instead of STDOUT.

collect :: DeadpanApp () Source

A client that responds to server collection messages.

Warning: this overwrites the "subscription-data" key of the collections field of the AppState.

dataAdded :: Callback Source

An app to handle the addition of subscription data items...

For Example: {"collection":"lists","msg":"added","id":F73xFyAuKrqsb2J3m,"fields":{"incompleteCount":6,"name":"Favorite Scientists"}}

Not especially useful on its own. You would usually use collect instead.

dataChanged :: Callback Source

An app to handle the modification of subscription data items...

For Example: {"collection":"lists","msg":"changed","id":TThFzYerrZaxmgjA7,"fields":{"name":"List Aasdf"}}

Not especially useful on its own. You would usually use collect instead.

dataRemoved :: Callback Source

An app to handle the removal of subscription data items...

For Example: {"collection":"lists","msg":"removed","id":By8CtgWGvbZfJPFsd}

Not especially useful on its own. You would usually use collect instead.

subscriptions :: Traversal' (AppState a) EJsonValue Source

A helper lens into the subscription data inside the collections section of the dynamic app state.

Example:

>>> :set -XOverloadedStrings
>>> _collections $ set (subscriptions . _EJObjectKey "songs") (Just ejnull) (AppState undefined ejnull undefined)
null

setServerID :: DeadpanApp () Source

A client that sets the session id if the server sends it {"server_id":"83752cf1-a9bf-a15e-b06a-91f110383550"}

The handler deletes itself when the session is set.

setSession :: DeadpanApp GUID Source

A client that sets the server_id if the server sends it {"msg":"connected","session":T6gBRv5RpCTwKcMSW}

TODO: The handler deletes itself when the session is set.

liftIO :: MonadIO m => forall a. IO a -> m a

Lift a computation from the IO monad.