summaryrefslogtreecommitdiff
path: root/src/Network/Tox/Session.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Network/Tox/Session.hs')
-rw-r--r--src/Network/Tox/Session.hs15
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
12import Control.Concurrent.STM 12import Control.Concurrent.STM
13import Control.Monad 13import Control.Monad
14import Control.Exception 14import Control.Exception
15import Data.Dependent.Sum
15import Data.Functor.Identity 16import Data.Functor.Identity
16import Data.Word 17import Data.Word
17import Network.Socket (SockAddr) 18import Network.Socket (SockAddr)
18 19
19import Crypto.Tox 20import Crypto.Tox
20import Data.PacketBuffer (PacketInboundEvent (..)) 21import Data.PacketBuffer (PacketInboundEvent (..))
21import Data.Tox.Message 22import Data.Tox.Msg
22import DPut 23import DPut
23import DebugTag 24import DebugTag
24import Network.Lossless 25import 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