diff options
author | joe <joe@jerkface.net> | 2018-05-19 20:38:36 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2018-05-19 20:38:36 -0400 |
commit | c3c89c536cd7524eaa510356b393e2d60fefdba6 (patch) | |
tree | 1c442c7db29f96a011af5ff5f013359ab93e4bb1 /examples/dhtd.hs | |
parent | 5fc282406abfe8cfb11ff0ce29562e334fb95755 (diff) |
Implemented command to list scheduled announcements.
Diffstat (limited to 'examples/dhtd.hs')
-rw-r--r-- | examples/dhtd.hs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/examples/dhtd.hs b/examples/dhtd.hs index 3e48e4bb..0439ed7e 100644 --- a/examples/dhtd.hs +++ b/examples/dhtd.hs | |||
@@ -769,6 +769,17 @@ clientSession s@Session{..} sock cnum h = do | |||
769 | -- | 769 | -- |
770 | -- a +friend <jid> <text> | 770 | -- a +friend <jid> <text> |
771 | -- a +dhtkey <key> | 771 | -- a +dhtkey <key> |
772 | ("a", "") -> cmd0 $ do | ||
773 | now <- getPOSIXTime | ||
774 | rs <- atomically $ do | ||
775 | as <- readTVar (scheduled $ announcer) | ||
776 | forM (PSQ.toList as) $ \(k,ptm,item) -> do | ||
777 | kstr <- unpackAnnounceKey announcer k | ||
778 | return [ show (ptm - now) | ||
779 | , show (itemStatusNum item) | ||
780 | , kstr | ||
781 | ] | ||
782 | hPutClient h $ showColumns rs | ||
772 | ("a", s) | Just DHT{..} <- Map.lookup netname dhts | 783 | ("a", s) | Just DHT{..} <- Map.lookup netname dhts |
773 | , not (null s) | 784 | , not (null s) |
774 | -> cmd0 $ do | 785 | -> cmd0 $ do |
@@ -805,6 +816,7 @@ clientSession s@Session{..} sock cnum h = do | |||
805 | reportit target = case op of | 816 | reportit target = case op of |
806 | '+' -> hPutClient h $ "Announcing at " ++ target ++ "." | 817 | '+' -> hPutClient h $ "Announcing at " ++ target ++ "." |
807 | '-' -> hPutClient h $ "Canceling " ++ target ++ "." | 818 | '-' -> hPutClient h $ "Canceling " ++ target ++ "." |
819 | -- mameth is for typical kademlia announce. | ||
808 | mameth = do | 820 | mameth = do |
809 | DHTAnnouncable { announceSendData | 821 | DHTAnnouncable { announceSendData |
810 | , announceParseData | 822 | , announceParseData |
@@ -824,6 +836,8 @@ clientSession s@Session{..} sock cnum h = do | |||
824 | announceInterval) | 836 | announceInterval) |
825 | dta | 837 | dta |
826 | reportit $ show $ announceTarget dta | 838 | reportit $ show $ announceTarget dta |
839 | -- lmeth is for atypical announce messages such as | ||
840 | -- Tox dht-key and friend-request messages. | ||
827 | lmeth :: Maybe (IO ()) | 841 | lmeth :: Maybe (IO ()) |
828 | lmeth = do | 842 | lmeth = do |
829 | DHTAnnouncable { announceSendData | 843 | DHTAnnouncable { announceSendData |