-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Secure WebSocket (WSS) clients
--   
--   Wuss is a library that lets you easily create secure WebSocket clients
--   over the WSS protocol. It is a small addition to <a>the websockets
--   package</a> and is adapted from existing solutions by
--   <a>@jaspervdj</a>, <a>@mpickering</a>, and <a>@elfenlaid</a>.
@package wuss
@version 1.1.9


-- | Wuss is a library that lets you easily create secure WebSocket clients
--   over the WSS protocol. It is a small addition to <a>the websockets
--   package</a> and is adapted from existing solutions by
--   <a>@jaspervdj</a>, <a>@mpickering</a>, and <a>@elfenlaid</a>.
--   
--   <h2>Example</h2>
--   
--   <pre>
--   import Wuss
--   
--   import Control.Concurrent (forkIO)
--   import Control.Monad (forever, unless, void)
--   import Data.Text (Text, pack)
--   import Network.WebSockets (ClientApp, receiveData, sendClose, sendTextData)
--   
--   main :: IO ()
--   main = runSecureClient "echo.websocket.org" 443 "/" ws
--   
--   ws :: ClientApp ()
--   ws connection = do
--       putStrLn "Connected!"
--   
--       void . forkIO . forever $ do
--           message &lt;- receiveData connection
--           print (message :: Text)
--   
--       let loop = do
--               line &lt;- getLine
--               unless (null line) $ do
--                   sendTextData connection (pack line)
--                   loop
--       loop
--   
--       sendClose connection (pack "Bye!")
--   </pre>
module Wuss

-- | A secure replacement for <a>runClient</a>.
--   
--   <pre>
--   &gt;&gt;&gt; let app _connection = return ()
--   
--   &gt;&gt;&gt; runSecureClient "echo.websocket.org" 443 "/" app
--   </pre>
runSecureClient :: HostName -> PortNumber -> String -> ClientApp a -> IO a

-- | A secure replacement for <a>runClientWith</a>.
--   
--   <pre>
--   &gt;&gt;&gt; let options = defaultConnectionOptions
--   
--   &gt;&gt;&gt; let headers = []
--   
--   &gt;&gt;&gt; let app _connection = return ()
--   
--   &gt;&gt;&gt; runSecureClientWith "echo.websocket.org" 443 "/" options headers app
--   </pre>
--   
--   If you want to run a secure client without certificate validation, use
--   <a>runClientWithStream</a>. For example:
--   
--   <pre>
--   let host = "echo.websocket.org"
--   let port = 443
--   let path = "/"
--   let options = defaultConnectionOptions
--   let headers = []
--   let tlsSettings = TLSSettingsSimple
--       -- This is the important setting.
--       { settingDisableCertificateValidation = True
--       , settingDisableSession = False
--       , settingUseServerName = False
--       }
--   let connectionParams = ConnectionParams
--       { connectionHostname = host
--       , connectionPort = port
--       , connectionUseSecure = Just tlsSettings
--       , connectionUseSocks = Nothing
--       }
--   
--   context &lt;- initConnectionContext
--   connection &lt;- connectTo context connectionParams
--   stream &lt;- makeStream
--       (fmap Just (connectionGetChunk connection))
--       (maybe (return ()) (connectionPut connection . toStrict))
--   runClientWithStream stream host path options headers $ \ connection -&gt; do
--       -- Do something with the connection.
--       return ()
--   </pre>
runSecureClientWith :: HostName -> PortNumber -> String -> ConnectionOptions -> Headers -> ClientApp a -> IO a

-- | Configures a secure WebSocket connection.
data Config
Config :: Connection -> IO ByteString -> Config

-- | How to get bytes from the connection. Typically
--   <a>connectionGetChunk</a>, but could be something else like
--   <a>connectionGetLine</a>.
[connectionGet] :: Config -> Connection -> IO ByteString

-- | The default <a>Config</a> value used by <a>runSecureClientWith</a>.
defaultConfig :: Config

-- | Runs a secure WebSockets client with the given <a>Config</a>.
runSecureClientWithConfig :: HostName -> PortNumber -> String -> Config -> ConnectionOptions -> Headers -> ClientApp a -> IO a
