diff options
author | Joe Crayne <joe@jerkface.net> | 2018-09-12 05:03:03 -0400 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2018-11-02 00:21:52 -0400 |
commit | ffaea2b2169a499aaa2ac72531beeb991714025a (patch) | |
tree | aaef07eb1ea57fd3cbdb885716955c1c9801da67 /src/Network/Tox | |
parent | 49dd57c58d9e9d5d31c35c8960686512703e0bae (diff) |
Lossless: Support for handling exceptions on send.
Diffstat (limited to 'src/Network/Tox')
-rw-r--r-- | src/Network/Tox/Session.hs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/Network/Tox/Session.hs b/src/Network/Tox/Session.hs index 525338b2..c672087f 100644 --- a/src/Network/Tox/Session.hs +++ b/src/Network/Tox/Session.hs | |||
@@ -11,6 +11,7 @@ module Network.Tox.Session | |||
11 | 11 | ||
12 | import Control.Concurrent.STM | 12 | import Control.Concurrent.STM |
13 | import Control.Monad | 13 | import Control.Monad |
14 | import Control.Exception | ||
14 | import Data.Functor.Identity | 15 | import Data.Functor.Identity |
15 | import Data.Word | 16 | import Data.Word |
16 | import Network.Socket (SockAddr) | 17 | import Network.Socket (SockAddr) |
@@ -132,7 +133,15 @@ plainHandshakeH sp saddr skey handshake = do | |||
132 | <- lossless (\cp a -> return $ fmap (,a) $ checkLossless $ runIdentity $ pktData cp) | 133 | <- lossless (\cp a -> return $ fmap (,a) $ checkLossless $ runIdentity $ pktData cp) |
133 | (\seqno p _ -> do | 134 | (\seqno p _ -> do |
134 | y <- encryptPacket sk $ bookKeeping seqno p | 135 | y <- encryptPacket sk $ bookKeeping seqno p |
135 | return (lossyness (msgID p) == Lossy, y)) | 136 | return OutgoingInfo |
137 | { oIsLossy = lossyness (msgID p) == Lossy | ||
138 | , oEncoded = y | ||
139 | , oHandleException = Just $ \e -> do | ||
140 | dput XUnexpected $ unlines | ||
141 | [ "<-- " ++ show e | ||
142 | , "<-- while sending " ++ show (seqno,p) ] | ||
143 | throwIO e | ||
144 | }) | ||
136 | () | 145 | () |
137 | t | 146 | t |
138 | let _ = t :: TransportA String () (CryptoPacket Identity) (CryptoPacket Encrypted) | 147 | let _ = t :: TransportA String () (CryptoPacket Identity) (CryptoPacket Encrypted) |