| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Network.WebSockets.Simple
- 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. (ToJSON send, FromJSON receive, MonadIO m, MonadBaseControl IO m, MonadThrow m, MonadCatch m) => WebSocketsApp m receive send -> ClientAppT m ()
- toServerAppT :: (ToJSON send, FromJSON receive, MonadIO m, MonadBaseControl IO m, MonadThrow m, MonadCatch m) => 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 #
Constructors
| WebSocketsApp | |
Fields
| |
Instances
| Profunctor (WebSocketsApp m) Source # | |
| Generic (WebSocketsApp m receive send) Source # | |
| Applicative m => Monoid (WebSocketsApp m receive send) Source # | |
| type Rep (WebSocketsApp m receive send) Source # | |
data WebSocketsAppParams m send Source #
Constructors
| WebSocketsAppParams | |
Instances
| Generic (WebSocketsAppParams m send) Source # | |
| type Rep (WebSocketsAppParams m send) Source # | |
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. |
data WebSocketsSimpleError Source #
Constructors
| JSONParseError ByteString |
Running
toClientAppT :: forall send receive m. (ToJSON send, FromJSON receive, MonadIO m, MonadBaseControl IO m, MonadThrow m, MonadCatch m) => 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, MonadThrow m, MonadCatch m) => WebSocketsApp m receive send -> 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 #