From 9102a47c6c68039a288a6ee8f43fe14b034ce356 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 18 Apr 2017 14:18:16 -0400 Subject: add --replay option This commit was sponsored by Ole-Morten Duesund on Patreon. --- Replay.hs | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'Replay.hs') diff --git a/Replay.hs b/Replay.hs index 599ca77..b50bc40 100644 --- a/Replay.hs +++ b/Replay.hs @@ -3,10 +3,29 @@ module Replay where import Types import Log import CmdLine +import Session + +import qualified Data.ByteString as B +import System.IO +import Control.Concurrent.Thread.Delay replay :: ReplayOpts -> IO () -replay opts = go =<< loadLog (replayLogFile opts) +replay opts = go Nothing =<< loadLog (replayLogFile opts) where - go [] = return () - go (l:ls) = do - go ls + go _ [] = sessionDone + go prevts (l:ls) = do + case prevts of + Nothing -> return () + Just t -> + let s = loggedTimestamp l - t + ms = s * 1000000 + in delay (ceiling ms) + + case loggedActivity l of + ActivityEntered {} -> return () + ActivitySeen a -> case activity a of + Rejected {} -> return () + Proto s -> do + B.hPut stdout (val (seenData s)) + hFlush stdout + go (Just $ loggedTimestamp l) ls -- cgit v1.2.3