diff options
author | Joe Crayne <joe@jerkface.net> | 2018-10-03 14:37:17 -0400 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2018-11-03 10:23:45 -0400 |
commit | 0c7768ba8eb62a6a74176f737a1c9c42308d5a8c (patch) | |
tree | 4c41e5cc4f6d0486466f2d74084b682c027aaf01 /examples/atox.hs | |
parent | 7ca3adad36ace11b523f7029fee4d43054f941ef (diff) |
Use seqence number context when serializing CryptoMessage.
Diffstat (limited to 'examples/atox.hs')
-rw-r--r-- | examples/atox.hs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/examples/atox.hs b/examples/atox.hs index 7845d911..3bae5203 100644 --- a/examples/atox.hs +++ b/examples/atox.hs | |||
@@ -92,7 +92,7 @@ data SetCmd = SetME | |||
92 | deriving (Eq,Bounded,Ord,Enum,Show) | 92 | deriving (Eq,Bounded,Ord,Enum,Show) |
93 | 93 | ||
94 | forkToxInputThread myRead = forkIO $ do | 94 | forkToxInputThread myRead = forkIO $ do |
95 | let myconduit = Conduit.sourceHandle myRead .| conduitGet2 (S.get :: Get CryptoMessage) -- :: ConduitT i CryptoMessage IO () | 95 | let myconduit = Conduit.sourceHandle myRead .| conduitGet2 (getCryptoMessage 0 :: Get CryptoMessage) -- :: ConduitT i CryptoMessage IO () |
96 | Conduit.runConduit (myconduit .| Conduit.awaitForever handle) | 96 | Conduit.runConduit (myconduit .| Conduit.awaitForever handle) |
97 | where | 97 | where |
98 | handle (UpToN IPC (B.uncons -> Just (ord -> toEnum -> i,arg))) = updateState i arg | 98 | handle (UpToN IPC (B.uncons -> Just (ord -> toEnum -> i,arg))) = updateState i arg |
@@ -113,7 +113,7 @@ forkToxInputThread myRead = forkIO $ do | |||
113 | modifyTVar' sMap (Map.insert key view) | 113 | modifyTVar' sMap (Map.insert key view) |
114 | 114 | ||
115 | updateState AppendMsg arg | 115 | updateState AppendMsg arg |
116 | = case S.decode arg of | 116 | = case getCryptoMessage 0 `S.runGet` arg of |
117 | Left str -> puts (packUtf8 str) | 117 | Left str -> puts (packUtf8 str) |
118 | Right msg -> liftIO . atomically $ do | 118 | Right msg -> liftIO . atomically $ do |
119 | me <- readTVar sMe | 119 | me <- readTVar sMe |
@@ -133,7 +133,7 @@ doit myReadFd myWriteFd = do | |||
133 | terminalInputLoop myWrite | 133 | terminalInputLoop myWrite |
134 | 134 | ||
135 | hSend :: MonadIO m => Handle -> CryptoMessage -> m () | 135 | hSend :: MonadIO m => Handle -> CryptoMessage -> m () |
136 | hSend h msg = liftIO $ B.hPutStrLn h (S.encode msg) | 136 | hSend h msg = liftIO $ B.hPutStrLn h (S.runPut $ putCryptoMessage 0 msg) |
137 | 137 | ||
138 | terminalInputLoop myWriteH = fix $ \loop -> do | 138 | terminalInputLoop myWriteH = fix $ \loop -> do |
139 | line <- B.getLine | 139 | line <- B.getLine |