diff options
author | James Crayne <jim.crayne@gmail.com> | 2018-05-30 05:49:20 +0000 |
---|---|---|
committer | James Crayne <jim.crayne@gmail.com> | 2018-05-30 05:49:20 +0000 |
commit | f315180cdc6c8a4f9790839b726b26b575295cf0 (patch) | |
tree | 569db11a627d70aa299931dc4d8f30b813e8fb93 /src/Network | |
parent | 59dc1f378a11d9ca57173e286dae9fcf3e586784 (diff) |
fix In/Out tags on addMsgToLastN
Diffstat (limited to 'src/Network')
-rw-r--r-- | src/Network/Tox/Crypto/Handlers.hs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/Network/Tox/Crypto/Handlers.hs b/src/Network/Tox/Crypto/Handlers.hs index b227e5ee..e6bb8371 100644 --- a/src/Network/Tox/Crypto/Handlers.hs +++ b/src/Network/Tox/Crypto/Handlers.hs | |||
@@ -755,7 +755,7 @@ sendOffline crypto session = sendCrypto crypto session (return ()) (OneByte OFFL | |||
755 | sendKill :: TransportCrypto -> NetCryptoSession -> IO (Either String ()) | 755 | sendKill :: TransportCrypto -> NetCryptoSession -> IO (Either String ()) |
756 | sendKill crypto session = do | 756 | sendKill crypto session = do |
757 | let cm=OneByte KillPacket | 757 | let cm=OneByte KillPacket |
758 | addMsgToLastN False (cm ^. messageType) session cm | 758 | addMsgToLastN False (cm ^. messageType) session (Out cm) |
759 | sendCrypto crypto session (return ()) cm | 759 | sendCrypto crypto session (return ()) cm |
760 | 760 | ||
761 | setNick :: TransportCrypto -> NetCryptoSession -> ByteString -> IO (Either String ()) | 761 | setNick :: TransportCrypto -> NetCryptoSession -> ByteString -> IO (Either String ()) |
@@ -769,7 +769,7 @@ setNick crypto session nick = do | |||
769 | view <- readTVar viewVar | 769 | view <- readTVar viewVar |
770 | writeTVar (svNick view) nick | 770 | writeTVar (svNick view) nick |
771 | let cm = UpToN NICKNAME nick | 771 | let cm = UpToN NICKNAME nick |
772 | addMsgToLastN False (cm ^. messageType) session cm | 772 | addMsgToLastN False (cm ^. messageType) session (Out cm) |
773 | sendCrypto crypto session updateLocal cm | 773 | sendCrypto crypto session updateLocal cm |
774 | 774 | ||
775 | setTyping :: TransportCrypto -> NetCryptoSession -> TypingStatus -> IO (Either String ()) | 775 | setTyping :: TransportCrypto -> NetCryptoSession -> TypingStatus -> IO (Either String ()) |
@@ -778,7 +778,7 @@ setTyping crypto session status = do | |||
778 | view <- readTVar (ncView session) | 778 | view <- readTVar (ncView session) |
779 | writeTVar (svTyping view) status | 779 | writeTVar (svTyping view) status |
780 | let cm = TwoByte TYPING (fromEnum8 status) | 780 | let cm = TwoByte TYPING (fromEnum8 status) |
781 | addMsgToLastN False (cm ^. messageType) session cm | 781 | addMsgToLastN False (cm ^. messageType) session (Out cm) |
782 | sendCrypto crypto session updateLocal cm | 782 | sendCrypto crypto session updateLocal cm |
783 | 783 | ||
784 | setNoSpam :: TransportCrypto -> NetCryptoSession -> Maybe NoSpam -> IO (Either String ()) | 784 | setNoSpam :: TransportCrypto -> NetCryptoSession -> Maybe NoSpam -> IO (Either String ()) |
@@ -795,7 +795,7 @@ setStatus crypto session status = do | |||
795 | view <- readTVar (ncView session) | 795 | view <- readTVar (ncView session) |
796 | writeTVar (svStatus view) status | 796 | writeTVar (svStatus view) status |
797 | let cm = TwoByte USERSTATUS (fromEnum8 status) | 797 | let cm = TwoByte USERSTATUS (fromEnum8 status) |
798 | addMsgToLastN False (cm ^. messageType) session cm | 798 | addMsgToLastN False (cm ^. messageType) session (Out cm) |
799 | sendCrypto crypto session updateLocal cm | 799 | sendCrypto crypto session updateLocal cm |
800 | 800 | ||
801 | setStatusMsg :: TransportCrypto -> NetCryptoSession -> ByteString -> IO (Either String ()) | 801 | setStatusMsg :: TransportCrypto -> NetCryptoSession -> ByteString -> IO (Either String ()) |
@@ -808,7 +808,7 @@ setStatusMsg crypto session msg = do | |||
808 | view <- readTVar (ncView session) | 808 | view <- readTVar (ncView session) |
809 | writeTVar (svStatusMsg view) msg | 809 | writeTVar (svStatusMsg view) msg |
810 | let cm = UpToN STATUSMESSAGE msg | 810 | let cm = UpToN STATUSMESSAGE msg |
811 | addMsgToLastN False (cm ^. messageType) session cm | 811 | addMsgToLastN False (cm ^. messageType) session (Out cm) |
812 | sendCrypto crypto session updateLocal cm | 812 | sendCrypto crypto session updateLocal cm |
813 | 813 | ||
814 | -- | handles nothings | 814 | -- | handles nothings |
@@ -866,7 +866,7 @@ hookHelper _ typ session cm | any ($ typ) [isKillPacket, isOFFLINE] = atomically | |||
866 | return Nothing | 866 | return Nothing |
867 | 867 | ||
868 | hookHelper handledFlg typ session cm = do | 868 | hookHelper handledFlg typ session cm = do |
869 | addMsgToLastN handledFlg typ session cm | 869 | addMsgToLastN handledFlg typ session (In cm) |
870 | atomically $ do | 870 | atomically $ do |
871 | idtmchans <- IntMap.assocs <$> readTVar (ncListeners session) | 871 | idtmchans <- IntMap.assocs <$> readTVar (ncListeners session) |
872 | mbChans | 872 | mbChans |
@@ -881,7 +881,7 @@ hookHelper handledFlg typ session cm = do | |||
881 | writeTMChan chan cm | 881 | writeTMChan chan cm |
882 | return Nothing | 882 | return Nothing |
883 | 883 | ||
884 | addMsgToLastN :: Bool -> MessageType -> NetCryptoSession -> CryptoMessage -> IO () | 884 | addMsgToLastN :: Bool -> MessageType -> NetCryptoSession -> InOrOut CryptoMessage -> IO () |
885 | addMsgToLastN handledFlg typ session cm = do | 885 | addMsgToLastN handledFlg typ session cm = do |
886 | let lastNQ = ncLastNMsgs session | 886 | let lastNQ = ncLastNMsgs session |
887 | msgNumVar = ncMsgNumVar session | 887 | msgNumVar = ncMsgNumVar session |
@@ -890,7 +890,7 @@ addMsgToLastN handledFlg typ session cm = do | |||
890 | num <- readTVar msgNumVar | 890 | num <- readTVar msgNumVar |
891 | view <- readTVar (ncView session) | 891 | view <- readTVar (ncView session) |
892 | snapshot <- viewSnapshot view | 892 | snapshot <- viewSnapshot view |
893 | (wraps,offset) <- PQ.enqueue lastNQ num (handledFlg,(snapshot,Out cm)) | 893 | (wraps,offset) <- PQ.enqueue lastNQ num (handledFlg,(snapshot,cm)) |
894 | capacity <- PQ.getCapacity lastNQ | 894 | capacity <- PQ.getCapacity lastNQ |
895 | let dropped = wraps * capacity + offset | 895 | let dropped = wraps * capacity + offset |
896 | modifyTVar' msgNumVar (+1) | 896 | modifyTVar' msgNumVar (+1) |