-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Simple interface to WebSockets. -- -- Simple interface to WebSockets. @package network-simple-ws @version 0.2 -- | Simple tools for establishing and using insecure WebSockets -- connections on top of TCP (i.e, ws://). -- -- See the network-simple-wss package for Secure WebSockets (i.e, -- wss://) support. -- -- Notice that, currently, this is package offers tools that are mostly -- intreresting from a client's point of view. Server side support will -- come later. module Network.Simple.WS data Connection -- | Receive a single full WebSockets message from the remote end as a lazy -- ByteString (potentially empty). -- -- Throws IOException if there is an unexpected Connection -- error. -- -- If the remote end requested the Connection to be closed, then -- Left will be returned instead, with a close code and reason -- description. -- -- recv :: MonadIO m => Connection -> m (Either (Word16, ByteString) ByteString) -- | Send a lazy ByteString (potentially empty) to the remote -- end as a single WebSockets message, in potentially multiple frames. -- -- If there is an issue with the Connection, an exception -- originating from the underlying Stream will be thrown. send :: MonadIO m => Connection -> ByteString -> m () -- | Send a close request to the remote end. -- -- After sending this request you should not use send anymore, but -- you should still continue to call recv to process any pending -- incomming messages. As soon as recv returns Left, you -- can consider the WebSocket Connection closed and can proceed to -- close the underlying transport. -- -- If there is an issue with the Connection, an exception -- originating from the underlying Stream will be thrown. close :: MonadIO m => Connection -> Word16 -> ByteString -> m () -- | Connect to the specified WebSockets server. connect :: (MonadIO m, MonadMask m) => HostName -> ServiceName -> ByteString -> [(ByteString, ByteString)] -> ((Connection, SockAddr) -> m r) -> m r -- | Like connect, but connects to the destination server through a -- SOCKS5 proxy. connectSOCKS5 :: (MonadIO m, MonadMask m) => HostName -> ServiceName -> HostName -> ServiceName -> ByteString -> [(ByteString, ByteString)] -> ((Connection, SockAddr, SockAddr) -> m r) -> m r -- | Obtain a Connection to the specified URI over the given -- Stream, connected to either a WebSockets server, or a Secure -- WebSockets server. clientConnectionFromStream :: MonadIO m => Stream -> HostName -> ServiceName -> ByteString -> [(ByteString, ByteString)] -> m Connection -- | Obtain a Stream implemented using the network Socket. -- You can use the network-simple library to get one of those. streamFromSocket :: MonadIO m => Socket -> m Stream