summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Crayne <jim.crayne@gmail.com>2018-06-08 09:34:13 +0000
committerJames Crayne <jim.crayne@gmail.com>2018-06-08 09:34:33 +0000
commit58c579498d062b6d8868926c386c42fb9dee753f (patch)
treefdcab3eba43ec70608043e4510f09a75f07ec43e
parent71f8dde4f3b7d7cd2274c3bcf235287457969095 (diff)
"sessions" comamnd progress column
Trade old "handled" and "unhandled" count columns for a column which shows the state of session.
-rw-r--r--Connection.hs2
-rw-r--r--examples/dhtd.hs12
2 files changed, 9 insertions, 5 deletions
diff --git a/Connection.hs b/Connection.hs
index 7228a0e4..58b4f4e5 100644
--- a/Connection.hs
+++ b/Connection.hs
@@ -13,7 +13,7 @@ data Status status
13 = Dormant 13 = Dormant
14 | InProgress status 14 | InProgress status
15 | Established 15 | Established
16 deriving (Eq,Ord,Functor) 16 deriving (Show,Eq,Ord,Functor)
17 17
18data Policy 18data Policy
19 = RefusingToConnect 19 = RefusingToConnect
diff --git a/examples/dhtd.hs b/examples/dhtd.hs
index fabf0661..b845f9df 100644
--- a/examples/dhtd.hs
+++ b/examples/dhtd.hs
@@ -622,14 +622,17 @@ clientSession s@Session{..} sock cnum h = do
622 -> cmd0 $ do 622 -> cmd0 $ do
623 sessions <- concat . Map.elems <$> (atomically $ readTVar (Tox.netCryptoSessionsByKey cryptosessions)) 623 sessions <- concat . Map.elems <$> (atomically $ readTVar (Tox.netCryptoSessionsByKey cryptosessions))
624 let sessionsReport = mapM showPerSession sessions 624 let sessionsReport = mapM showPerSession sessions
625 headers = ["SessionID", "YourKey", "TheirKey", "NextMsg", "Dropped","Handled","Unhandled"] 625 headers = ["SessionID", "YourKey", "TheirKey", "NextMsg", "Dropped" {-,"Handled","Unhandled" -}
626 ,"Progress" ]
626 showPerSession (Tox.NCrypto 627 showPerSession (Tox.NCrypto
627 { ncSessionId = id 628 { ncState = progressVar
629 , ncSessionId = id
628 , ncMyPublicKey = yourkey 630 , ncMyPublicKey = yourkey
629 , ncTheirPublicKey = theirkey 631 , ncTheirPublicKey = theirkey
630 , ncLastNMsgs = lastN 632 , ncLastNMsgs = lastN
631 , ncSockAddr = sockAddr 633 , ncSockAddr = sockAddr
632 }) = do 634 }) = do
635 progress <- atomically $ readTVar progressVar
633 (num,dropped) <- atomically $ liftA2 (,) (CB.getTotal lastN) (CB.getDropped lastN) 636 (num,dropped) <- atomically $ liftA2 (,) (CB.getTotal lastN) (CB.getDropped lastN)
634 as <- atomically (CB.cyclicBufferViewList lastN) 637 as <- atomically (CB.cyclicBufferViewList lastN)
635 let (h,u) = partition (fst . snd) as 638 let (h,u) = partition (fst . snd) as
@@ -640,8 +643,9 @@ clientSession s@Session{..} sock cnum h = do
640 , show (Tox.key2id theirkey)-- "TheirKey" 643 , show (Tox.key2id theirkey)-- "TheirKey"
641 , show num -- "NextMsg" 644 , show num -- "NextMsg"
642 , show dropped -- "Dropped" 645 , show dropped -- "Dropped"
643 , show countHandled -- "Handled" 646 -- , show countHandled -- "Handled"
644 , show countUnhandled -- "Unhandled" 647 -- , show countUnhandled -- "Unhandled"
648 , show progress
645 ] 649 ]
646 if null sessions 650 if null sessions
647 then hPutClient h "No sessions." 651 then hPutClient h "No sessions."