diff options
Diffstat (limited to 'src/Network/Tox/Session.hs')
-rw-r--r-- | src/Network/Tox/Session.hs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/Network/Tox/Session.hs b/src/Network/Tox/Session.hs index 18e17fb6..189967fa 100644 --- a/src/Network/Tox/Session.hs +++ b/src/Network/Tox/Session.hs | |||
@@ -12,13 +12,14 @@ module Network.Tox.Session | |||
12 | import Control.Concurrent.STM | 12 | import Control.Concurrent.STM |
13 | import Control.Monad | 13 | import Control.Monad |
14 | import Control.Exception | 14 | import Control.Exception |
15 | import Data.Dependent.Sum | ||
15 | import Data.Functor.Identity | 16 | import Data.Functor.Identity |
16 | import Data.Word | 17 | import Data.Word |
17 | import Network.Socket (SockAddr) | 18 | import Network.Socket (SockAddr) |
18 | 19 | ||
19 | import Crypto.Tox | 20 | import Crypto.Tox |
20 | import Data.PacketBuffer (PacketInboundEvent (..)) | 21 | import Data.PacketBuffer (PacketInboundEvent (..)) |
21 | import Data.Tox.Message | 22 | import Data.Tox.Msg |
22 | import DPut | 23 | import DPut |
23 | import DebugTag | 24 | import DebugTag |
24 | import Network.Lossless | 25 | import Network.Lossless |
@@ -136,10 +137,10 @@ plainHandshakeH sp saddr skey handshake = do | |||
136 | forM_ m $ \(sid, t) -> do | 137 | forM_ m $ \(sid, t) -> do |
137 | (t2,resend,getMissing) | 138 | (t2,resend,getMissing) |
138 | <- lossless (\cp a -> return $ fmap (,a) $ checkLossless $ runIdentity $ pktData cp) | 139 | <- lossless (\cp a -> return $ fmap (,a) $ checkLossless $ runIdentity $ pktData cp) |
139 | (\seqno p _ -> do | 140 | (\seqno p@(Pkt m :=> _) _ -> do |
140 | y <- encryptPacket sk $ bookKeeping seqno p | 141 | y <- encryptPacket sk $ bookKeeping seqno p |
141 | return OutgoingInfo | 142 | return OutgoingInfo |
142 | { oIsLossy = lossyness (msgID p) == Lossy | 143 | { oIsLossy = lossyness m == Lossy |
143 | , oEncoded = y | 144 | , oEncoded = y |
144 | , oHandleException = Just $ \e -> do | 145 | , oHandleException = Just $ \e -> do |
145 | dput XUnexpected $ unlines | 146 | dput XUnexpected $ unlines |
@@ -151,7 +152,7 @@ plainHandshakeH sp saddr skey handshake = do | |||
151 | t | 152 | t |
152 | let _ = t :: TransportA String () (CryptoPacket Identity) (CryptoPacket Encrypted) | 153 | let _ = t :: TransportA String () (CryptoPacket Identity) (CryptoPacket Encrypted) |
153 | _ = t2 :: Transport String () CryptoMessage | 154 | _ = t2 :: Transport String () CryptoMessage |
154 | sendMessage t2 () $ OneByte ONLINE | 155 | sendMessage t2 () $ (Pkt ONLINE ==> ()) |
155 | spOnNewSession sp Session | 156 | spOnNewSession sp Session |
156 | { sOurKey = skey | 157 | { sOurKey = skey |
157 | , sTheirAddr = saddr | 158 | , sTheirAddr = saddr |
@@ -236,5 +237,7 @@ checkLossless cd@CryptoData{ bufferStart = ack | |||
236 | , bufferData = x } = tag no x' ack | 237 | , bufferData = x } = tag no x' ack |
237 | where | 238 | where |
238 | x' = decodeRawCryptoMsg cd | 239 | x' = decodeRawCryptoMsg cd |
239 | tag = case lossyness (msgID x') of Lossy -> PacketReceivedLossy | 240 | tag = case someLossyness (msgID x') of Lossy -> PacketReceivedLossy |
240 | _ -> PacketReceived | 241 | _ -> PacketReceived |
242 | |||
243 | |||