packages feed

websockets-snap 0.8.1.0 → 0.8.2.0

raw patch · 2 files changed

+14/−8 lines, 2 files

Files

src/Network/WebSockets/Snap.hs view
@@ -54,13 +54,18 @@   ---------------------------------------------------------------------------------copyIterateeToMVar :: MVar Chunk -> E.Iteratee ByteString IO ()-copyIterateeToMVar mvar = E.catchError go handler+copyIterateeToMVar :: ((Int -> Int) -> IO ())+                   -> MVar Chunk+                   -> E.Iteratee ByteString IO ()+copyIterateeToMVar tickle mvar = E.catchError go handler   where     go = do         mbs <- EL.head         case mbs of-            Just x  -> lift (putMVar mvar (Chunk x)) >> go+            Just x  -> do+                lift (tickle (max 60))+                lift (putMVar mvar (Chunk x))+                go             Nothing -> lift (putMVar mvar Eof)      handler se@(SomeException e) = case cast e of@@ -136,24 +141,25 @@             pc = WS.PendingConnection                     { WS.pendingOptions  = options'                     , WS.pendingRequest  = fromSnapRequest rq-                    , WS.pendingOnAccept = forkPingThread+                    , WS.pendingOnAccept = forkPingThread tickle                     , WS.pendingIn       = is                     , WS.pendingOut      = os                     }          _ <- lift $ forkIO $ app pc >> throwTo thisThread ServerAppDone-        copyIterateeToMVar mvar+        copyIterateeToMVar tickle mvar   -------------------------------------------------------------------------------- -- | Start a ping thread in the background-forkPingThread :: WS.Connection -> IO ()-forkPingThread conn = do+forkPingThread :: ((Int -> Int) -> IO ()) -> WS.Connection -> IO ()+forkPingThread tickle conn = do     _ <- forkIO pingThread     return ()   where     pingThread = handle ignore $ forever $ do         WS.sendPing conn (BC.pack "ping")+        tickle (min 15)         threadDelay $ 30 * 1000 * 1000      ignore :: SomeException -> IO ()
websockets-snap.cabal view
@@ -1,5 +1,5 @@ Name:          websockets-snap-Version:       0.8.1.0+Version:       0.8.2.0 Synopsis:      Snap integration for the websockets library Description:   Snap integration for the websockets library License:       BSD3