Safe Haskell | None |
---|---|
Language | Haskell2010 |
Network.WebSockets.Simple
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
- dimap' :: Monad m => (receive' -> m receive) -> (send -> send') -> WebSocketsApp m receive send -> WebSocketsApp m receive' send'
- dimapJson :: ToJSON send => FromJSON receive => MonadThrow m => WebSocketsApp m receive send -> WebSocketsApp m Value Value
- dimapStringify :: MonadThrow m => WebSocketsApp m Value Value -> WebSocketsApp m Text Text
- 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 ()
- toClientAppTString :: MonadBaseControl IO m stM => Extractable stM => MonadCatch m => MonadIO m => WebSocketsApp m Text Text -> ClientAppT m ()
- toClientAppTBinary :: MonadBaseControl IO m stM => Extractable stM => MonadCatch m => MonadIO m => WebSocketsApp m ByteString ByteString -> ClientAppT m ()
- toClientAppTBoth :: forall m stM. MonadBaseControl IO m stM => Extractable stM => MonadCatch m => MonadIO m => WebSocketsApp m Text Text -> WebSocketsApp m ByteString ByteString -> ClientAppT m ()
- accept :: MonadIO m => ClientAppT m () -> 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 #
Constructors
WebSocketsApp | |
Fields
|
Instances
data WebSocketsAppParams m send Source #
Constructors
WebSocketsAppParams | |
Instances
Generic (WebSocketsAppParams m send) Source # | |
Defined in Network.WebSockets.Simple Associated Types type Rep (WebSocketsAppParams m send) :: Type -> Type # Methods 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.2.0-L03lTnnHzRSFz8OEoxt1sv" 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
Constructors
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 Methods (==) :: ConnectionException -> ConnectionException -> Bool # (/=) :: ConnectionException -> ConnectionException -> Bool # | |
Show ConnectionException | |
Defined in Network.WebSockets.Types Methods showsPrec :: Int -> ConnectionException -> ShowS # show :: ConnectionException -> String # showList :: [ConnectionException] -> ShowS # | |
Exception ConnectionException | |
Defined in Network.WebSockets.Types Methods toException :: ConnectionException -> SomeException # fromException :: SomeException -> Maybe ConnectionException # |
data CloseOrigin Source #
Constructors
ClosedOnSend | |
ClosedOnClose | |
ClosedOnReceive |
Instances
Eq CloseOrigin Source # | |
Defined in Network.WebSockets.Simple | |
Show CloseOrigin Source # | |
Defined in Network.WebSockets.Simple Methods showsPrec :: Int -> CloseOrigin -> ShowS # show :: CloseOrigin -> String # showList :: [CloseOrigin] -> ShowS # |
data WebSocketsSimpleError Source #
Constructors
JSONParseError Text | |
JSONValueError Value |
Instances
Running
dimap' :: Monad m => (receive' -> m receive) -> (send -> send') -> WebSocketsApp m receive send -> WebSocketsApp m receive' send' Source #
dimapJson :: ToJSON send => FromJSON receive => MonadThrow m => WebSocketsApp m receive send -> WebSocketsApp m Value Value Source #
dimapStringify :: MonadThrow m => WebSocketsApp m Value Value -> WebSocketsApp m Text Text Source #
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.
toClientAppTString :: MonadBaseControl IO m stM => Extractable stM => MonadCatch m => MonadIO m => WebSocketsApp m Text Text -> ClientAppT m () Source #
toClientAppTBinary :: MonadBaseControl IO m stM => Extractable stM => MonadCatch m => MonadIO m => WebSocketsApp m ByteString ByteString -> ClientAppT m () Source #
toClientAppTBoth :: forall m stM. MonadBaseControl IO m stM => Extractable stM => MonadCatch m => MonadIO m => WebSocketsApp m Text Text -> WebSocketsApp m ByteString ByteString -> ClientAppT m () Source #
accept :: MonadIO m => ClientAppT m () -> ServerAppT m Source #
Utilities
Arguments
:: 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 #