module WebServer (runWebServer) where import ClassyPrelude import Network.HTTP.Types import Network.Wai import Network.Wai.Handler.Warp (run) import WebSocket (ServerState, broadcast) -- todo: use ReaderT instead of curring the state -- then add a MVar for storing the room Data, including users that are not in any room yet app :: MVar ServerState -> Application app state req respond = do putStrLn "I've done some IO here" withMVar state $ \currenState -> broadcast "body of req" currenState respond $ responseLBS status200 [("Content-Type", "text/plain")] "" runWebServer :: MVar ServerState -> IO () runWebServer state = do putStrLn "http://localhost:8080/" run 8080 $ app state