-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Box websockets -- -- Websockets built with the box library. @package box-socket @version 0.5.2.0 -- | Abstract sockets connected to Boxes. module Box.Socket.Types -- | Whether to stay open after an emitter ends or send a close after a -- delay in seconds. data PostSend StayOpen :: PostSend CloseAfter :: Double -> PostSend -- | Whether a socket remains open or closed after an action finishes. data SocketStatus SocketOpen :: SocketStatus SocketClosed :: SocketStatus SocketBroken :: SocketStatus instance GHC.Show.Show Box.Socket.Types.PostSend instance GHC.Classes.Eq Box.Socket.Types.PostSend instance GHC.Generics.Generic Box.Socket.Types.PostSend instance GHC.Show.Show Box.Socket.Types.SocketStatus instance GHC.Classes.Eq Box.Socket.Types.SocketStatus instance GHC.Generics.Generic Box.Socket.Types.SocketStatus -- | TCP Boxes. module Box.TCP -- | TCP configuration -- --
--   >>> defaultTCPConfig
--   TCPConfig {hostPreference = HostAny, host = "127.0.0.1", port = "3566", chunk = 2048, endLine = "\n"}
--   
data TCPConfig TCPConfig :: HostPreference -> Text -> Text -> Int -> Text -> TCPConfig [hostPreference] :: TCPConfig -> HostPreference [host] :: TCPConfig -> Text [port] :: TCPConfig -> Text [chunk] :: TCPConfig -> Int [endLine] :: TCPConfig -> Text -- | default defaultTCPConfig :: TCPConfig -- | An active TCP environment data TCPEnv TCPEnv :: Socket -> SockAddr -> TCPEnv [socket] :: TCPEnv -> Socket [sockaddr] :: TCPEnv -> SockAddr -- | Basic type for a socket. data () => Socket -- | connect an action (ie a client) connect :: TCPConfig -> Codensity IO TCPEnv -- | serve an action (ie a server) serve :: TCPConfig -> Codensity IO TCPEnv -- | Commit received ByteStrings. receiver :: TCPConfig -> Committer IO ByteString -> Socket -> IO () -- | Send emitted ByteStrings. sender :: Emitter IO ByteString -> Socket -> IO SocketStatus -- | A two-way connection. duplex :: TCPConfig -> PostSend -> Box IO ByteString ByteString -> Socket -> IO () -- | A Box action for a client. clientBox :: TCPConfig -> PostSend -> Box IO ByteString ByteString -> IO () -- | A client CoBox. clientCoBox :: TCPConfig -> PostSend -> CoBox IO ByteString ByteString -- | A Box action for a server. serverBox :: TCPConfig -> PostSend -> Box IO ByteString ByteString -> IO () -- | A server CoBox. serverCoBox :: TCPConfig -> PostSend -> CoBox IO ByteString ByteString -- | A receiver that applies a response function to received ByteStrings. responseServer :: TCPConfig -> (ByteString -> Maybe ByteString) -> IO () instance GHC.Generics.Generic Box.TCP.TCPConfig instance GHC.Classes.Eq Box.TCP.TCPConfig instance GHC.Show.Show Box.TCP.TCPConfig -- | It's a box. It's a TCP socket. It's an example. module Box.TCP.Example -- | A server that only sends and a client that only receives. -- -- The result here is indeterminate: it can return ["ab"] or ["a","b"] -- depending on when the client and servers fire. -- --
--   senderExample ["a","b"]
--   
-- -- senderExample :: [ByteString] -> IO [ByteString] -- | A server that only sends and a client that only receives. -- --
--   >>> senderLinesExample ["a","b"]
--   ["a","b"]
--   
senderLinesExample :: [Text] -> IO [Text] -- | echo server example -- --
--   >>> echoExample ["a","b","c"]
--   ["echo: abc"]
--   
echoExample :: [ByteString] -> IO [ByteString] -- | "q" to close the client, reads and writes from std -- --
--   >>> clientIO
--   *** Exception: Network.Socket.connect: <socket: ...>: does not exist (Connection refused)
--   
clientIO :: IO () -- | "q" to close a client socket down. Ctrl-c to close the server. Reads -- and writes from std. -- --
--   >>> a <- async serverIO
--   
--   >>> serverIO
--   *** Exception: Network.Socket.bind: resource busy (Address already in use)
--   
-- --
--   >>> cancel a
--   
serverIO :: IO () -- | Websocket components built with Boxes. module Box.Websocket -- | Socket configuration -- --
--   >>> defaultSocketConfig
--   SocketConfig {host = "127.0.0.1", port = 9160, path = "/"}
--   
data SocketConfig SocketConfig :: Text -> Int -> Text -> SocketConfig [host] :: SocketConfig -> Text [port] :: SocketConfig -> Int [path] :: SocketConfig -> Text -- | official default defaultSocketConfig :: SocketConfig -- | connect an action (ie a client) connect :: SocketConfig -> Codensity IO Connection -- | serve an action (ie a server) serve :: SocketConfig -> Codensity IO Connection -- | Given a PendingConnection, provide a Connection -- continuation. pending :: PendingConnection -> Codensity IO Connection -- | Attach a box to a PendingConnection in wai-style. serverApp :: Box IO Text Text -> PendingConnection -> IO () -- | Commit received messages, finalising on receiving a -- CloseRequest receiver :: WebSocketsData a => Committer IO a -> Connection -> IO () -- | Commit received messages, finalising on receiving a -- CloseRequest, with event logging. receiver_ :: (WebSocketsData a, Show a) => Committer IO a -> Committer IO Text -> Connection -> IO () -- | Send emitted messages, returning whether the socket remained open (the -- Emitter ran out of emits) or closed (a CloseRequest was -- received). sender :: WebSocketsData a => Emitter IO a -> Connection -> IO SocketStatus -- | Send emitted messages, returning whether the socket remained open (the -- Emitter ran out of emits) or closed (a CloseRequest was -- received). With event logging. sender_ :: (WebSocketsData a, Show a) => Emitter IO a -> Committer IO Text -> Connection -> IO SocketStatus -- | A two-way connection. Closes if it receives a CloseRequest -- exception, or if PostSend is CloseAfter. duplex :: WebSocketsData a => PostSend -> Box IO a a -> Connection -> IO () -- | A two-way connection. Closes if it receives a CloseRequest -- exception, or if PostSend is CloseAfter. With event -- logging. duplex_ :: (WebSocketsData a, Show a) => PostSend -> Committer IO Text -> Box IO a a -> Connection -> IO () -- | A Box action for a client. clientBox :: WebSocketsData a => SocketConfig -> PostSend -> Box IO a a -> IO () -- | A client CoBox. clientCoBox :: WebSocketsData a => SocketConfig -> PostSend -> CoBox IO a a -- | A Box action for a server. serverBox :: WebSocketsData a => SocketConfig -> PostSend -> Box IO a a -> IO () -- | A server CoBox. serverCoBox :: WebSocketsData a => SocketConfig -> PostSend -> CoBox IO a a -- | A receiver that applies a response function to received messages. responseServer :: WebSocketsData a => SocketConfig -> (a -> Maybe a) -> IO () instance GHC.Generics.Generic Box.Websocket.SocketConfig instance GHC.Classes.Eq Box.Websocket.SocketConfig instance GHC.Show.Show Box.Websocket.SocketConfig -- | It's a box. It's a websocket. It's an example. module Box.Websocket.Example -- | A server that only sends and a client that only receives. -- --
--   >>> senderExample ["a","b"]
--   ["a","b"]
--   
senderExample :: [Text] -> IO [Text] -- | echo server example -- --
--   >>> echoExample ["a","b","c"]
--   ["echo: a","echo: b","echo: c"]
--   
echoExample :: [Text] -> IO [Text] -- | echo server example, with event logging. -- -- The order of events is non-deterministic, so this is a rough guide: -- --
--   echoLogExample ["a","b","c"]
--   
-- -- (["echo: a","echo: b","echo: c"],["client:sender_:emit:Just -- "a"","client:sender_:sendTextData:Right ()","client:sender_:emit:Just -- "b"","client:sender_:sendTextData:Right ()","client:sender_:emit:Just -- "c"","client:sender_:sendTextData:Right -- ()","client:sender_:emit:Nothing","client:sender_ closed with -- SocketOpen","server:receiver_:receiveData:Right -- "a"","server:receiver_:receiveData:Right -- "b"","server:receiver_:receiveData:Right -- "c"","server:sender_:emit:Just "echo: -- a"","server:sender_:sendTextData:Right ()","server:sender_:emit:Just -- "echo: b"","server:sender_:sendTextData:Right -- ()","server:sender_:emit:Just "echo: -- c"","server:sender_:sendTextData:Right -- ()","client:receiver_:receiveData:Right "echo: -- a"","client:receiver_:receiveData:Right "echo: -- b"","client:receiver_:receiveData:Right "echo: -- c"","server:receiver_:receiveData:Left (CloseRequest 1000 "close after -- sending")","server:receiver_ -- closed","client:receiver_:receiveData:Left (CloseRequest 1000 "close -- after sending")","client:receiver_ closed","client:duplex_ -- closed","server:duplex_ closed"]) echoLogExample :: [Text] -> IO ([Text], [Text]) -- | "q" to close the client, reads and writes from std -- --
--   >>> clientIO
--   *** Exception: Network.Socket.connect: <socket: ...>: does not exist (Connection refused)
--   
clientIO :: IO () -- | "q" to close a client socket down. Ctrl-c to close the server. Reads -- and writes from std. -- --
--   >>> a <- async serverIO
--   
--   >>> serverIO
--   *** Exception: Network.Socket.bind: resource busy (Address already in use)
--   
-- --
--   >>> cancel a
--   
serverIO :: IO ()