websockets-simple-0.0.5: Simpler interface to the websockets api

Safe HaskellNone
LanguageHaskell2010

Network.WebSockets.Simple

Synopsis

Documentation

data WebSocketsAppParams send m Source

Constructors

WebSocketsAppParams 

Fields

send :: send -> m ()
 
close :: m ()
 

Instances

data WebSocketsApp send receive m Source

Constructors

WebSocketsApp 

Fields

onOpen :: WebSocketsAppParams send m -> m ()
 
onReceive :: WebSocketsAppParams send m -> receive -> m ()
 
onClose :: Maybe (Word16, ByteString) -> m ()

Either was a clean close, with CloseRequest params, or was unclean. Note that to implement backoff strategies, you should catch your ConnectionException outside this simple app, and only after you've runClient or server, because the Connection will be different.

Instances

Generic (WebSocketsApp send receive m) Source 
type Rep (WebSocketsApp send receive m) Source 

hoistWebSocketsApp :: (forall a. m a -> n a) -> (forall a. n a -> m a) -> WebSocketsApp send receive m -> WebSocketsApp send receive n Source

toClientAppT :: forall send receive m. (ToJSON send, FromJSON receive, MonadBaseControl IO m, MonadThrow m, MonadCatch m) => WebSocketsApp send receive m -> ClientAppT m (Maybe WebSocketsAppThreads) Source

This can throw a WebSocketSimpleError when json parsing fails. However, do note: the onOpen is called once, but is still forked when called. Likewise, the onReceive function is called every time a (parsable) response is received from the other party, and is forked on every invocation.

toClientAppT' :: (ToJSON send, FromJSON receive, MonadBaseControl IO m, MonadThrow m, MonadCatch m) => WebSocketsApp send receive m -> ClientAppT m () Source

toServerAppT :: (ToJSON send, FromJSON receive, MonadBaseControl IO m, MonadThrow m, MonadCatch m) => WebSocketsApp send receive m -> ServerAppT m Source

expBackoffStrategy Source

Arguments

:: (MonadBaseControl IO m, MonadCatch m) 
=> m a

The run app

-> m a 

A simple backoff strategy, which (per second), will increasingly delay at 2^soFar, until soFar >= 5minutes, where it will then routinely poll every 5 minutes.

data WebSocketsAppThreads Source

Constructors

WebSocketsAppThreads 

Fields

onOpenThread :: Async ()
 
onReceiveThreads :: TChan (Async ())