websockets-rpc-0.5.1: Simple streaming RPC mechanism using WebSockets

Safe HaskellNone
LanguageHaskell2010

Network.WebSockets.RPC

Contents

Synopsis

Server

data RPCServerParams rep com m Source #

Constructors

RPCServerParams 

Fields

  • reply :: rep -> m ()

    dispatch a reply

  • complete :: com -> m ()

    dispatch a onComplete

type RPCServer sub sup rep com m Source #

Arguments

 = RPCServerParams rep com m 
-> Either sub sup

handle incoming message

-> m () 

rpcServer :: forall sub sup rep com m. (ToJSON rep, ToJSON com, FromJSON sub, FromJSON sup, MonadIO m, MonadThrow m, MonadBaseControl IO m) => RPCServer sub sup rep com m -> ServerAppT (WebSocketServerRPCT sub sup m) Source #

May throw a WebSocketRPCParseFailure if the opposing party sends bad data

Client

data RPCClientParams sup m Source #

Constructors

RPCClientParams 

Fields

  • supply :: sup -> m ()

    dispatch a supply

  • cancel :: m ()

    cancel the RPC call

data RPCClient sub sup rep com m Source #

Constructors

RPCClient 

Fields

rpcClient :: forall sub sup rep com m. (ToJSON sub, ToJSON sup, FromJSON rep, FromJSON com, MonadIO m, MonadThrow m, MonadCatch m) => ((RPCClient sub sup rep com m -> WebSocketClientRPCT rep com m ()) -> WebSocketClientRPCT rep com m ()) -> ClientAppT (WebSocketClientRPCT rep com m) () Source #

May throw a WebSocketRPCParseFailure if the opposing party sends bad data

Re-Exports

data WebSocketServerRPCT sub sup m a Source #

Instances

MonadReader r m => MonadReader r (WebSocketServerRPCT sub sup m) Source # 

Methods

ask :: WebSocketServerRPCT sub sup m r #

local :: (r -> r) -> WebSocketServerRPCT sub sup m a -> WebSocketServerRPCT sub sup m a #

reader :: (r -> a) -> WebSocketServerRPCT sub sup m a #

MonadState s m => MonadState s (WebSocketServerRPCT sub sup m) Source # 

Methods

get :: WebSocketServerRPCT sub sup m s #

put :: s -> WebSocketServerRPCT sub sup m () #

state :: (s -> (a, s)) -> WebSocketServerRPCT sub sup m a #

MonadWriter w m => MonadWriter w (WebSocketServerRPCT sub sup m) Source # 

Methods

writer :: (a, w) -> WebSocketServerRPCT sub sup m a #

tell :: w -> WebSocketServerRPCT sub sup m () #

listen :: WebSocketServerRPCT sub sup m a -> WebSocketServerRPCT sub sup m (a, w) #

pass :: WebSocketServerRPCT sub sup m (a, w -> w) -> WebSocketServerRPCT sub sup m a #

MonadTrans (WebSocketServerRPCT sub sup) Source # 

Methods

lift :: Monad m => m a -> WebSocketServerRPCT sub sup m a #

Monad m => Monad (WebSocketServerRPCT sub sup m) Source # 

Methods

(>>=) :: WebSocketServerRPCT sub sup m a -> (a -> WebSocketServerRPCT sub sup m b) -> WebSocketServerRPCT sub sup m b #

(>>) :: WebSocketServerRPCT sub sup m a -> WebSocketServerRPCT sub sup m b -> WebSocketServerRPCT sub sup m b #

return :: a -> WebSocketServerRPCT sub sup m a #

fail :: String -> WebSocketServerRPCT sub sup m a #

Functor m => Functor (WebSocketServerRPCT sub sup m) Source # 

Methods

fmap :: (a -> b) -> WebSocketServerRPCT sub sup m a -> WebSocketServerRPCT sub sup m b #

(<$) :: a -> WebSocketServerRPCT sub sup m b -> WebSocketServerRPCT sub sup m a #

Applicative m => Applicative (WebSocketServerRPCT sub sup m) Source # 

Methods

pure :: a -> WebSocketServerRPCT sub sup m a #

(<*>) :: WebSocketServerRPCT sub sup m (a -> b) -> WebSocketServerRPCT sub sup m a -> WebSocketServerRPCT sub sup m b #

(*>) :: WebSocketServerRPCT sub sup m a -> WebSocketServerRPCT sub sup m b -> WebSocketServerRPCT sub sup m b #

(<*) :: WebSocketServerRPCT sub sup m a -> WebSocketServerRPCT sub sup m b -> WebSocketServerRPCT sub sup m a #

MonadIO m => MonadIO (WebSocketServerRPCT sub sup m) Source # 

Methods

liftIO :: IO a -> WebSocketServerRPCT sub sup m a #

MonadThrow m => MonadThrow (WebSocketServerRPCT sub sup m) Source # 

Methods

throwM :: Exception e => e -> WebSocketServerRPCT sub sup m a #

MonadCatch m => MonadCatch (WebSocketServerRPCT sub sup m) Source # 

Methods

catch :: Exception e => WebSocketServerRPCT sub sup m a -> (e -> WebSocketServerRPCT sub sup m a) -> WebSocketServerRPCT sub sup m a #

MonadMask m => MonadMask (WebSocketServerRPCT sub sup m) Source # 

Methods

mask :: ((forall a. WebSocketServerRPCT sub sup m a -> WebSocketServerRPCT sub sup m a) -> WebSocketServerRPCT sub sup m b) -> WebSocketServerRPCT sub sup m b #

uninterruptibleMask :: ((forall a. WebSocketServerRPCT sub sup m a -> WebSocketServerRPCT sub sup m a) -> WebSocketServerRPCT sub sup m b) -> WebSocketServerRPCT sub sup m b #

Generic (WebSocketServerRPCT sub sup m a) Source # 

Associated Types

type Rep (WebSocketServerRPCT sub sup m a) :: * -> * #

Methods

from :: WebSocketServerRPCT sub sup m a -> Rep (WebSocketServerRPCT sub sup m a) x #

to :: Rep (WebSocketServerRPCT sub sup m a) x -> WebSocketServerRPCT sub sup m a #

type Rep (WebSocketServerRPCT sub sup m a) Source # 
type Rep (WebSocketServerRPCT sub sup m a) = D1 (MetaData "WebSocketServerRPCT" "Network.WebSockets.RPC.Trans.Server" "websockets-rpc-0.5.1-6X1Zm3uuB2XCbtHnBwwB4Y" True) (C1 (MetaCons "WebSocketServerRPCT" PrefixI True) (S1 (MetaSel (Just Symbol "runWebSocketServerRPCT") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (ReaderT * (Env sub sup m) m a))))

data WebSocketClientRPCT rep com m a Source #

Instances

MonadReader r m => MonadReader r (WebSocketClientRPCT rep com m) Source # 

Methods

ask :: WebSocketClientRPCT rep com m r #

local :: (r -> r) -> WebSocketClientRPCT rep com m a -> WebSocketClientRPCT rep com m a #

reader :: (r -> a) -> WebSocketClientRPCT rep com m a #

MonadState s m => MonadState s (WebSocketClientRPCT rep com m) Source # 

Methods

get :: WebSocketClientRPCT rep com m s #

put :: s -> WebSocketClientRPCT rep com m () #

state :: (s -> (a, s)) -> WebSocketClientRPCT rep com m a #

MonadWriter w m => MonadWriter w (WebSocketClientRPCT rep com m) Source # 

Methods

writer :: (a, w) -> WebSocketClientRPCT rep com m a #

tell :: w -> WebSocketClientRPCT rep com m () #

listen :: WebSocketClientRPCT rep com m a -> WebSocketClientRPCT rep com m (a, w) #

pass :: WebSocketClientRPCT rep com m (a, w -> w) -> WebSocketClientRPCT rep com m a #

MonadTrans (WebSocketClientRPCT rep com) Source # 

Methods

lift :: Monad m => m a -> WebSocketClientRPCT rep com m a #

Monad m => Monad (WebSocketClientRPCT rep com m) Source # 

Methods

(>>=) :: WebSocketClientRPCT rep com m a -> (a -> WebSocketClientRPCT rep com m b) -> WebSocketClientRPCT rep com m b #

(>>) :: WebSocketClientRPCT rep com m a -> WebSocketClientRPCT rep com m b -> WebSocketClientRPCT rep com m b #

return :: a -> WebSocketClientRPCT rep com m a #

fail :: String -> WebSocketClientRPCT rep com m a #

Functor m => Functor (WebSocketClientRPCT rep com m) Source # 

Methods

fmap :: (a -> b) -> WebSocketClientRPCT rep com m a -> WebSocketClientRPCT rep com m b #

(<$) :: a -> WebSocketClientRPCT rep com m b -> WebSocketClientRPCT rep com m a #

Applicative m => Applicative (WebSocketClientRPCT rep com m) Source # 

Methods

pure :: a -> WebSocketClientRPCT rep com m a #

(<*>) :: WebSocketClientRPCT rep com m (a -> b) -> WebSocketClientRPCT rep com m a -> WebSocketClientRPCT rep com m b #

(*>) :: WebSocketClientRPCT rep com m a -> WebSocketClientRPCT rep com m b -> WebSocketClientRPCT rep com m b #

(<*) :: WebSocketClientRPCT rep com m a -> WebSocketClientRPCT rep com m b -> WebSocketClientRPCT rep com m a #

MonadIO m => MonadIO (WebSocketClientRPCT rep com m) Source # 

Methods

liftIO :: IO a -> WebSocketClientRPCT rep com m a #

MonadThrow m => MonadThrow (WebSocketClientRPCT rep com m) Source # 

Methods

throwM :: Exception e => e -> WebSocketClientRPCT rep com m a #

MonadCatch m => MonadCatch (WebSocketClientRPCT rep com m) Source # 

Methods

catch :: Exception e => WebSocketClientRPCT rep com m a -> (e -> WebSocketClientRPCT rep com m a) -> WebSocketClientRPCT rep com m a #

MonadMask m => MonadMask (WebSocketClientRPCT rep com m) Source # 

Methods

mask :: ((forall a. WebSocketClientRPCT rep com m a -> WebSocketClientRPCT rep com m a) -> WebSocketClientRPCT rep com m b) -> WebSocketClientRPCT rep com m b #

uninterruptibleMask :: ((forall a. WebSocketClientRPCT rep com m a -> WebSocketClientRPCT rep com m a) -> WebSocketClientRPCT rep com m b) -> WebSocketClientRPCT rep com m b #

Generic (WebSocketClientRPCT rep com m a) Source # 

Associated Types

type Rep (WebSocketClientRPCT rep com m a) :: * -> * #

Methods

from :: WebSocketClientRPCT rep com m a -> Rep (WebSocketClientRPCT rep com m a) x #

to :: Rep (WebSocketClientRPCT rep com m a) x -> WebSocketClientRPCT rep com m a #

type Rep (WebSocketClientRPCT rep com m a) Source # 
type Rep (WebSocketClientRPCT rep com m a) = D1 (MetaData "WebSocketClientRPCT" "Network.WebSockets.RPC.Trans.Client" "websockets-rpc-0.5.1-6X1Zm3uuB2XCbtHnBwwB4Y" True) (C1 (MetaCons "WebSocketClientRPCT" PrefixI True) (S1 (MetaSel (Just Symbol "runWebSocketClientRPCT") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (ReaderT * (Env rep com m) m a))))

runClientAppTBackingOff :: (forall a. m a -> IO a) -> String -> Int -> String -> ClientAppT m () -> IO () Source #

rpcServerSimple :: forall sub sup rep com m. (MonadBaseControl IO m, MonadIO m) => RPCServer sub sup rep com m -> WebSocketsApp (Either (Reply rep) (Complete com)) (Either (Subscribe sub) (Supply sup)) (WebSocketServerRPCT sub sup m) Source #

Note that this does not ping-pong.

rpcClientSimple :: forall sub sup rep com m. MonadIO m => RPCClient sub sup rep com m -> WebSocketClientRPCT rep com m (WebSocketsApp (Either (Subscribe sub) (Supply sup)) (Either (Reply rep) (Complete com)) (WebSocketClientRPCT rep com m)) Source #

Note, does not support pingpong

runWebSocketClientRPCTSimple :: Monad m => (forall a. WebSocketClientRPCT rep com m a -> m a) -> WebSocketsApp (Either (Subscribe sub) (Supply sup)) (Either (Reply rep) (Complete com)) (WebSocketClientRPCT rep com m) -> WebSocketsApp (Either (Subscribe sub) (Supply sup)) (Either (Reply rep) (Complete com)) m Source #

runWebSocketServerRPCTSimple :: Monad m => (forall a. WebSocketServerRPCT sub sup m a -> m a) -> WebSocketsApp (Either (Reply rep) (Complete com)) (Either (Subscribe sub) (Supply sup)) (WebSocketServerRPCT sub sup m) -> WebSocketsApp (Either (Reply rep) (Complete com)) (Either (Subscribe sub) (Supply sup)) m Source #