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

-- | Provide a bridge between WAI and the websockets package.
--   
--   API docs and the README are available at
--   http://www.stackage.org/package/wai-websockets.
@package wai-websockets
@version 3.0.1.2

module Network.Wai.Handler.WebSockets

-- | Upgrade a websockets ServerApp to a wai
--   Application. Uses the given backup Application to handle
--   Requests that are not WebSocket requests.
--   
--   
--   websocketsOr opts ws_app backup_app = \req respond ->
--       case websocketsApp opts ws_app req of
--           Nothing  -> backup_app req send_response
--           Just res -> respond res
--   
--   
--   For example, below is an Application that sends "Hello,
--   client!" to each connected client.
--   
--   
--   app :: Application
--   app = websocketsOr defaultConnectionOptions wsApp backupApp
--     where
--       wsApp :: ServerApp
--       wsApp pending_conn = do
--           conn <- acceptRequest pending_conn
--           sendTextData conn ("Hello, client!" :: Text)
--   
--       backupApp :: Application
--       backupApp _ respond = respond $ responseLBS status400 [] "Not a WebSocket request"
--   
websocketsOr :: ConnectionOptions -> ServerApp -> Application -> Application

-- | Handle a single wai Request with the given
--   websockets ServerApp. Returns Nothing if the
--   Request is not a WebSocket request, Just otherwise.
--   
--   Usually, websocketsOr is more convenient.
websocketsApp :: ConnectionOptions -> ServerApp -> Request -> Maybe Response

-- | Returns whether or not the given Request is a WebSocket
--   request.
isWebSocketsReq :: Request -> Bool
getRequestHead :: Request -> RequestHead

-- | Internal function to run the WebSocket io-streams using the conduit
--   library.
runWebSockets :: ConnectionOptions -> RequestHead -> (PendingConnection -> IO a) -> IO ByteString -> (ByteString -> IO ()) -> IO a
