From 8fe574a8f1f2f71b68c89aeacccd05d084a4003d Mon Sep 17 00:00:00 2001 From: James Crayne Date: Mon, 28 May 2018 19:54:59 +0000 Subject: ncLastNMsgs is now CyclicBuffer type --- examples/dhtd.hs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'examples') diff --git a/examples/dhtd.hs b/examples/dhtd.hs index 4b79b132..ce1e1b16 100644 --- a/examples/dhtd.hs +++ b/examples/dhtd.hs @@ -108,6 +108,7 @@ import Connection import ToxToXMPP import qualified Connection.Tcp as Tcp (ConnectionEvent(..)) import Control.Concurrent.Supply +import qualified Data.CyclicBuffer as CB showReport :: [(String,String)] -> String @@ -708,14 +709,11 @@ clientSession s@Session{..} sock cnum h = do { ncSessionId = id , ncMyPublicKey = yourkey , ncTheirPublicKey = theirkey - , ncLastNMsgs = msgQ + , ncLastNMsgs = lastN , ncSockAddr = sockAddr - , ncMsgNumVar = msgNumVar - , ncDropCntVar = dropCntVar }) = do - num <- atomically (readTVar msgNumVar) - dropped <- atomically (readTVar dropCntVar) - as <- atomically (packetQueueViewList msgQ) + (num,dropped) <- atomically $ liftA2 (,) (CB.getTotal lastN) (CB.getDropped lastN) + as <- atomically (CB.cyclicBufferViewList lastN) let (h,u) = partition (fst . snd) as countHandled = length h countUnhandled = length u -- cgit v1.2.3