From 31cca9914be082552119e0be863f7a16629c079c Mon Sep 17 00:00:00 2001 From: joe Date: Fri, 28 Jun 2013 21:19:13 -0400 Subject: Attempt to control buffer sends with renderBytes... --- Presence/ServerC.hs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'Presence/ServerC.hs') diff --git a/Presence/ServerC.hs b/Presence/ServerC.hs index 36e2d7bf..ae0bf154 100644 --- a/Presence/ServerC.hs +++ b/Presence/ServerC.hs @@ -18,6 +18,7 @@ import Data.ByteString.Char8 ) import qualified Data.ByteString.Char8 as S ( hPutStr + , hPutStrLn ) import System.IO ( IOMode(..) @@ -115,18 +116,20 @@ doServer (HCons family port) g = runServer port (runConn g) packets :: MonadIO m => Handle -> Source m S.ByteString packets h = do - packet <- lift $ liftIO $ getPacket h + packet <- liftIO $ getPacket h yield packet - isEof <- lift $ liftIO $ hIsEOF h + isEof <- liftIO $ hIsEOF h when (not isEof) (packets h) where getPacket h = do { hWaitForInput h (-1) ; hGetNonBlocking h 1024 } outgoing :: MonadIO m => Handle -> Sink S.ByteString m () outgoing h = do + liftIO . L.putStrLn $ "outgoing: waiting" mpacket <- await + liftIO . L.putStrLn $ "outgoing: got packet " <++> bshow mpacket maybe (return ()) - (\r -> (lift . liftIO . S.hPutStr h $ r) >> outgoing h) + (\r -> (liftIO . S.hPutStrLn h $ r) >> outgoing h) mpacket -- cgit v1.2.3