blob: 1ca0ae712f4d663a6b19d96af857a9b75091790e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
module Role.Watcher where
import Types
import Log
import Pty
import CmdLine
import SessionID
import Role.Developer (run', processSessionStart, getServerMessage, emitOutput)
import Control.Concurrent.STM
import Control.Concurrent.STM.TMChan
import Data.Time.Clock.POSIX
run :: WatchOpts -> IO ()
run = run' watcher . watchUrl
watcher :: TMChan (Message Entered) -> TMChan LogMessage -> SessionID -> IO ()
watcher _ichan ochan _ = inRawMode $ do
(st, startoutput) <- processSessionStart ochan nullLogger
emitOutput startoutput
go st
where
go st = do
ts <- getPOSIXTime
v <- atomically $ getServerMessage ochan st ts
case v of
Nothing -> return ()
Just (o, _msg) -> do
emitOutput o
go st
|