diff options
author | Joey Hess <joeyh@joeyh.name> | 2017-04-24 15:24:52 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2017-04-24 16:03:46 -0400 |
commit | 9a8d3bc531647d8b96e66e6daabf2176a1df4afb (patch) | |
tree | 5f198a02e59fbec20b38ad347db37cad97b3ed0d /Role/Watcher.hs | |
parent | 7b2bcfab392d387b89c3c251f0c9a8b9c0203aa8 (diff) | |
download | debug-me-9a8d3bc531647d8b96e66e6daabf2176a1df4afb.tar.gz |
switch to TMChans so they can be closed when a connection is Done
Diffstat (limited to 'Role/Watcher.hs')
-rw-r--r-- | Role/Watcher.hs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Role/Watcher.hs b/Role/Watcher.hs index 620733c..6ed1a6b 100644 --- a/Role/Watcher.hs +++ b/Role/Watcher.hs @@ -7,17 +7,21 @@ import CmdLine import SessionID import Control.Concurrent.STM +import Control.Concurrent.STM.TMChan import Role.Developer (run', processSessionStart, getUserMessage, emitOutput) run :: WatchOpts -> IO () run = run' watcher . watchUrl -watcher :: TChan (Message Entered) -> TChan (Message Seen) -> SessionID -> IO () +watcher :: TMChan (Message Entered) -> TMChan (Message Seen) -> SessionID -> IO () watcher _ichan ochan _ = inRawMode $ do st <- processSessionStart ochan nullLogger go st where go st = do - (o, _msg) <- atomically $ getUserMessage ochan st - emitOutput o - go st + v <- atomically $ getUserMessage ochan st + case v of + Nothing -> return () + Just (o, _msg) -> do + emitOutput o + go st |