packages feed

labyrinth-server 0.1.4.0 → 0.1.4.1

raw patch · 2 files changed

+8/−8 lines, 2 files

Files

labyrinth-server.cabal view
@@ -1,5 +1,5 @@ name:                labyrinth-server-version:             0.1.4.0+version:             0.1.4.1 synopsis:            A complicated turn-based game - Web server description:         Players take turns in a labyrinth, competing with each                      other to pick a treasure and carry it out. They only know
src/LabyrinthServer.hs view
@@ -141,16 +141,16 @@     conn <- WS.acceptRequest rq     ci <- mkConnInfo conn     addWatcher site watch ci-    forever $ handleConnClosed (removeWatcher site watch ci) $ do+    forever $ handleConnError (removeWatcher site watch ci) $ do         -- Ignore all received messages         WS.receive conn         return () -handleConnClosed :: IO a -> IO a -> IO a-handleConnClosed handler = handleJust whenClosed (const handler)-    where whenClosed e = case fromException e :: Maybe WS.ConnectionException of-                             Just ce -> Just ce-                             _ -> Nothing+handleConnError :: IO a -> IO a -> IO a+handleConnError handler = handleJust whenWSError (const handler)+                         . handleJust whenIOError (const handler)+    where whenWSError e = fromException e :: Maybe WS.ConnectionException+          whenIOError e = fromException e :: Maybe IOError  withWatchers :: LabyrinthServer -> (Watchers -> IO Watchers) -> IO () withWatchers site = modifyMVar_ $ lsWatchers site@@ -191,7 +191,7 @@ notifyWatchers site watch = liftIO $ withWatchers site $ \watchersMap -> do     let watchers = fromMaybe [] $ M.lookup watch watchersMap     value <- watchTargetValue site watch-    let notifyOne watchersMap ci = handleConnClosed+    let notifyOne watchersMap ci = handleConnError             (return $ removeWatcher' watch ci watchersMap)             $ do                 WS.sendTextData (ciConn ci) (encode value)