-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Composable websockets clients
--
-- See README at
-- https://github.com/athanclark/websockets-simple#readme
@package websockets-simple
@version 0.1.3
module Network.WebSockets.Simple
data WebSocketsApp m receive send
WebSocketsApp :: (WebSocketsAppParams m send -> m ()) -> (WebSocketsAppParams m send -> receive -> m ()) -> (CloseOrigin -> ConnectionException -> m ()) -> WebSocketsApp m receive send
[onOpen] :: WebSocketsApp m receive send -> WebSocketsAppParams m send -> m ()
[onReceive] :: WebSocketsApp m receive send -> WebSocketsAppParams m send -> receive -> m ()
-- | Should be re-entrant; this exception is caught in all uses of
-- send, even if used in a dead Connection in a lingering
-- thread.
[onClose] :: WebSocketsApp m receive send -> CloseOrigin -> ConnectionException -> m ()
data WebSocketsAppParams m send
WebSocketsAppParams :: (send -> m ()) -> m () -> WebSocketsAppParams m send
[send] :: WebSocketsAppParams m send -> send -> m ()
[close] :: WebSocketsAppParams m send -> m ()
-- | Various exceptions that can occur while receiving or transmitting
-- messages
data ConnectionException
-- | 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.
CloseRequest :: Word16 -> ByteString -> ConnectionException
-- | 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.
ConnectionClosed :: ConnectionException
-- | The client sent garbage, i.e. we could not parse the WebSockets
-- stream.
ParseException :: String -> ConnectionException
-- | The client sent invalid UTF-8. Note that this exception will only be
-- thrown if strict decoding is set in the connection options.
UnicodeException :: String -> ConnectionException
data CloseOrigin
ClosedOnSend :: CloseOrigin
ClosedOnClose :: CloseOrigin
ClosedOnReceive :: CloseOrigin
data WebSocketsSimpleError
JSONParseError :: ByteString -> WebSocketsSimpleError
-- | This can throw a WebSocketSimpleError to the main thread via
-- link when json parsing fails.
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
-- | 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.
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
instance GHC.Show.Show Network.WebSockets.Simple.WebSocketsSimpleError
instance GHC.Classes.Eq Network.WebSockets.Simple.WebSocketsSimpleError
instance GHC.Generics.Generic Network.WebSockets.Simple.WebSocketsSimpleError
instance GHC.Generics.Generic (Network.WebSockets.Simple.WebSocketsApp m receive send)
instance GHC.Show.Show Network.WebSockets.Simple.CloseOrigin
instance GHC.Classes.Eq Network.WebSockets.Simple.CloseOrigin
instance GHC.Generics.Generic (Network.WebSockets.Simple.WebSocketsAppParams m send)
instance GHC.Exception.Type.Exception Network.WebSockets.Simple.WebSocketsSimpleError
instance Data.Profunctor.Unsafe.Profunctor (Network.WebSockets.Simple.WebSocketsApp m)
instance GHC.Base.Applicative m => GHC.Base.Semigroup (Network.WebSockets.Simple.WebSocketsApp m receive send)
instance GHC.Base.Applicative m => GHC.Base.Monoid (Network.WebSockets.Simple.WebSocketsApp m receive send)
module Network.WebSockets.Simple.PingPong
-- | Uses the JSON literal [] as the ping message
newtype PingPong a
PingPong :: Maybe a -> PingPong a
[getPingPong] :: PingPong a -> Maybe a
pingPong :: (MonadBaseControl IO m stM, Extractable stM) => Int -> WebSocketsApp m receive send -> m (WebSocketsApp m (PingPong receive) (PingPong send))
instance Data.Aeson.Types.ToJSON.ToJSON a => Data.Aeson.Types.ToJSON.ToJSON (Network.WebSockets.Simple.PingPong.PingPong a)
instance Data.Aeson.Types.FromJSON.FromJSON a => Data.Aeson.Types.FromJSON.FromJSON (Network.WebSockets.Simple.PingPong.PingPong a)
module Test.WebSockets.Simple
-- | Runs two WebSocketsApps together in a forged channel.
runConnected :: forall send receive m stM. (MonadIO m, MonadBaseControl IO m stM, Extractable stM) => WebSocketsApp m receive send -> WebSocketsApp m send receive -> m (Async (), Async (), TChan send, TChan receive)