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

Safe HaskellNone
LanguageHaskell2010

Web.DDP.Deadpan.DSL

Description

An EDSL designed to make writing deadpan applications easy!

This DSL is a simple decoration of some application specific functions arround an RWST monad instance.

TODO: Check that this is still correct...

  type deadpanapp a = Control.Monad.Rws.Rwst
                        network.websockets.connection
                        ()
                        callbackset
                        io
                        a

A core cabal of functions are exported from this module which are then put to use in web.ddp.deadpan to create an expressive dsl for creating ddp applications.

The main functions exported are...

TODO: Ensure these are up to date...

  • rundeadpan
  • sethandler
  • deletehandler
  • setdefaulthandler
  • senddata
  • sendmessage

these allow you to...

  • run a deadpan application with some initial set of callbacks
  • set new values for response handlers
  • delete existing response handlers
  • set a handler to act when no existing handler matches the incomming message
  • send an ejsonvalue to the server (low-level)
  • send messages to be interpreted as rpc calls

... respectively.

There is also a `control.lens.lens` collections provided into a single ejsonvalue.

This can be used to...

  • Retrieve any current collection data
  • Set collection data manually
  • Perform actions on collection data in callbacks

Synopsis

Documentation

type Lookup a = Map Text a Source

data AppState cb Source

Constructors

AppState 

Fields

_defaultCallback :: cb

The callback to run when no other callbacks match

_callbackSet :: Lookup cb

Callbacks to match against by message

_collections :: TVar EJsonValue

Shared data Expected to be an EJObject , _localState :: ls -- ^ Thread-Local state -- TODO: Currently disabled

defaultCallback :: forall cb. Lens' (AppState cb) cb Source

callbackSet :: forall cb. Lens' (AppState cb) (Lookup cb) Source

runDeadpan :: DeadpanApp a -> Connection -> AppState Callback -> IO (a, AppState Callback) Source

The order of these args match that of runRWST

sendData :: EJsonValue -> DeadpanApp () Source

A low-level function intended to be able to send any arbitrary data to the server. Given that all messages to the server are intended to fit the "message" format, You should probably use sendMessage instead. TODO: Decide if this should perform the request in a seperate thread...

sendMessage :: Text -> EJsonValue -> DeadpanApp () Source

Send a particular type of message (indicated by the key) to the server. This should be the primary means of [client -> server] communication by a client application.

fork :: DeadpanApp a -> DeadpanApp () Source

Provides a way to fork a background thread running the app provided TODO: Consider returning the thread-id

module Data.EJson

module Data.Text