summaryrefslogtreecommitdiffhomepage
path: root/Replay.hs
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2017-04-18 14:18:16 -0400
committerJoey Hess <joeyh@joeyh.name>2017-04-18 14:20:09 -0400
commit9102a47c6c68039a288a6ee8f43fe14b034ce356 (patch)
treee88eefe101db6381625518c68c7d8ed9e1fe3bac /Replay.hs
parentccdb5a3c6a28cc6745d337bdb67e62d70216ef7e (diff)
downloaddebug-me-9102a47c6c68039a288a6ee8f43fe14b034ce356.tar.gz
add --replay option
This commit was sponsored by Ole-Morten Duesund on Patreon.
Diffstat (limited to 'Replay.hs')
-rw-r--r--Replay.hs27
1 files changed, 23 insertions, 4 deletions
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