packages feed

Hach 0.1.1 → 0.1.2

raw patch · 4 files changed

+8/−7 lines, 4 files

Files

Hach.cabal view
@@ -1,5 +1,5 @@ Name:                   Hach-Version:                0.1.1+Version:                0.1.2 Category:               Network Synopsis:               Simple chat Description:            Simple example of chat application. Consists of 3 components: hach-server, hach-client (simple console client), hach-nclient (vty-ui client).
nclient/NClient/GUI.hs view
@@ -54,7 +54,7 @@     schedule $       do a:as <- S.words (fromS2C m) . region_width <$> getCurrentSize messages          addMessage (formatter Tail m) a messages-         forM_ as $ \γ -> addMessage (formatter Full m) γ messages+         forM_ as $ \g -> addMessage (formatter Full m) g messages     threadDelay 10000   --   runUi c defaultContext
server/Server.hs view
@@ -20,16 +20,17 @@   (s, _) <- accept sock   h <- socketToHandle s ReadWriteMode   hSetBuffering h LineBuffering+  hSetBuffering stdout NoBuffering   forkIO $ handle (onDisconnect ch) $ clientProcessing history storage ch h cId   serve sock history storage ch $ cId + 1   where     onDisconnect :: Chan (Int, S2C) -> SomeException -> IO ()     onDisconnect ch' _ = do       maybeNick <- getNick storage cId-      τ <- getCurrentTime+      t <- getCurrentTime       case maybeNick of-        Just η -> do-          writeChan ch' (cId, leftClientM η τ)+        Just n -> do+          writeChan ch' (cId, leftClientM n t)           delId storage cId           showStorage storage         Nothing -> putStrLn "Error: undefined user has left conversation"
server/Server/History.hs view
@@ -17,7 +17,7 @@ emptyHistory = History <$> newMVar S.empty  putMessage :: History -> S2C -> IO ()-putMessage (History a) μ = modifyMVar_ a (\h -> return $ h S.|> μ)+putMessage (History a) m = modifyMVar_ a (\h -> return $ h S.|> m)  getMessages :: History -> IO (S.Seq S2C) getMessages (History a) = readMVar a@@ -25,5 +25,5 @@ lastNMinutes :: Int -> Timestamp -> S.Seq S2C -> S.Seq S2C lastNMinutes minutes currentTime = S.takeWhileR inLastMinutes   where inLastMinutes :: S2C -> Bool-        inLastMinutes μ = diffUTCTime currentTime (time μ) < nominalMinutes+        inLastMinutes m = diffUTCTime currentTime (time m) < nominalMinutes           where nominalMinutes = 60 * fromIntegral minutes :: NominalDiffTime