Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data WebSocketsApp m receive send = WebSocketsApp {
- onOpen :: WebSocketsAppParams m send -> m ()
- onReceive :: WebSocketsAppParams m send -> receive -> m ()
- onClose :: CloseOrigin -> ConnectionException -> m ()
- data WebSocketsAppParams m send = WebSocketsAppParams {}
- data ConnectionException
- data CloseOrigin
- data WebSocketsSimpleError = JSONParseError ByteString
- toClientAppT :: forall send receive m stM. ToJSON send => FromJSON receive => MonadIO m => MonadBaseControl IO m stM => MonadThrow m => MonadCatch m => Extractable stM => WebSocketsApp m receive send -> ClientAppT m ()
- toServerAppT :: (ToJSON send, FromJSON receive, MonadIO m, MonadBaseControl IO m stM, MonadThrow m, MonadCatch m, Extractable stM) => WebSocketsApp m receive send -> ServerAppT m
- expBackoffStrategy :: forall m a. MonadIO m => m a -> m (ConnectionException -> m a)
- hoistWebSocketsApp :: (forall a. m a -> n a) -> (forall a. n a -> m a) -> WebSocketsApp m receive send -> WebSocketsApp n receive send
Types
data WebSocketsApp m receive send Source #
WebSocketsApp | |
|
Instances
data WebSocketsAppParams m send Source #
Instances
Generic (WebSocketsAppParams m send) Source # | |
Defined in Network.WebSockets.Simple type Rep (WebSocketsAppParams m send) :: Type -> Type # from :: WebSocketsAppParams m send -> Rep (WebSocketsAppParams m send) x # to :: Rep (WebSocketsAppParams m send) x -> WebSocketsAppParams m send # | |
type Rep (WebSocketsAppParams m send) Source # | |
Defined in Network.WebSockets.Simple type Rep (WebSocketsAppParams m send) = D1 (MetaData "WebSocketsAppParams" "Network.WebSockets.Simple" "websockets-simple-0.1.3-Fufzk7UDpdJ1e23KI5oUaK" False) (C1 (MetaCons "WebSocketsAppParams" PrefixI True) (S1 (MetaSel (Just "send") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (send -> m ())) :*: S1 (MetaSel (Just "close") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 (m ())))) |
data ConnectionException #
Various exceptions that can occur while receiving or transmitting messages
CloseRequest Word16 ByteString | The peer has requested that the connection be closed, and included a close code and a reason for closing. When receiving this exception, no more messages can be sent. Also, the server is responsible for closing the TCP connection once this exception is received. See http://tools.ietf.org/html/rfc6455#section-7.4 for a list of close codes. |
ConnectionClosed | The peer unexpectedly closed the connection while we were trying to receive some data. This is a violation of the websocket RFC since the TCP connection should only be closed after sending and receiving close control messages. |
ParseException String | The client sent garbage, i.e. we could not parse the WebSockets stream. |
UnicodeException String | The client sent invalid UTF-8. Note that this exception will only be thrown if strict decoding is set in the connection options. |
Instances
Eq ConnectionException | |
Defined in Network.WebSockets.Types (==) :: ConnectionException -> ConnectionException -> Bool # (/=) :: ConnectionException -> ConnectionException -> Bool # | |
Show ConnectionException | |
Defined in Network.WebSockets.Types showsPrec :: Int -> ConnectionException -> ShowS # show :: ConnectionException -> String # showList :: [ConnectionException] -> ShowS # | |
Exception ConnectionException | |
data CloseOrigin Source #
Instances
Eq CloseOrigin Source # | |
Defined in Network.WebSockets.Simple (==) :: CloseOrigin -> CloseOrigin -> Bool # (/=) :: CloseOrigin -> CloseOrigin -> Bool # | |
Show CloseOrigin Source # | |
Defined in Network.WebSockets.Simple showsPrec :: Int -> CloseOrigin -> ShowS # show :: CloseOrigin -> String # showList :: [CloseOrigin] -> ShowS # |
data WebSocketsSimpleError Source #
Instances
Eq WebSocketsSimpleError Source # | |
Defined in Network.WebSockets.Simple (==) :: WebSocketsSimpleError -> WebSocketsSimpleError -> Bool # (/=) :: WebSocketsSimpleError -> WebSocketsSimpleError -> Bool # | |
Show WebSocketsSimpleError Source # | |
Defined in Network.WebSockets.Simple showsPrec :: Int -> WebSocketsSimpleError -> ShowS # show :: WebSocketsSimpleError -> String # showList :: [WebSocketsSimpleError] -> ShowS # | |
Generic WebSocketsSimpleError Source # | |
Defined in Network.WebSockets.Simple type Rep WebSocketsSimpleError :: Type -> Type # | |
Exception WebSocketsSimpleError Source # | |
type Rep WebSocketsSimpleError Source # | |
Defined in Network.WebSockets.Simple type Rep WebSocketsSimpleError = D1 (MetaData "WebSocketsSimpleError" "Network.WebSockets.Simple" "websockets-simple-0.1.3-Fufzk7UDpdJ1e23KI5oUaK" False) (C1 (MetaCons "JSONParseError" PrefixI False) (S1 (MetaSel (Nothing :: Maybe Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 ByteString))) |
Running
toClientAppT :: forall send receive m stM. ToJSON send => FromJSON receive => MonadIO m => MonadBaseControl IO m stM => MonadThrow m => MonadCatch m => Extractable stM => WebSocketsApp m receive send -> ClientAppT m () Source #
This can throw a WebSocketSimpleError
to the main thread via link
when json parsing fails.
toServerAppT :: (ToJSON send, FromJSON receive, MonadIO m, MonadBaseControl IO m stM, MonadThrow m, MonadCatch m, Extractable stM) => WebSocketsApp m receive send -> ServerAppT m Source #
Utilities
:: MonadIO m | |
=> m a | Action to call, like pinging a scoped channel to trigger the reconnect |
-> m (ConnectionException -> 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.
hoistWebSocketsApp :: (forall a. m a -> n a) -> (forall a. n a -> m a) -> WebSocketsApp m receive send -> WebSocketsApp n receive send Source #