diff options
author | joe <joe@jerkface.net> | 2017-10-31 17:42:15 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2017-10-31 17:42:15 -0400 |
commit | 9eef4cbd00586df2fad36f3cab3d04b807b92e2f (patch) | |
tree | bc3448768e0d83a864d4f26e6d4a229865d1b9b7 /examples | |
parent | 4b39ca7d2c7d1592fd5109b9208539ae88fce093 (diff) |
WIP: a command (recurring announcements) (Part 4)
Diffstat (limited to 'examples')
-rw-r--r-- | examples/dhtd.hs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/examples/dhtd.hs b/examples/dhtd.hs index fa4ce95b..931e1ba0 100644 --- a/examples/dhtd.hs +++ b/examples/dhtd.hs | |||
@@ -311,6 +311,8 @@ forkSearch method nid DHTQuery{qsearch,qshowTok,qshowR} dhtSearches dhtBuckets | |||
311 | , searchResults = results | 311 | , searchResults = results |
312 | } | 312 | } |
313 | modifyTVar' dhtSearches $ Map.insert (method,nid) new | 313 | modifyTVar' dhtSearches $ Map.insert (method,nid) new |
314 | -- Finally, we write the search loop action into a tvar that will be executed in a new | ||
315 | -- thread. | ||
314 | writeTVar kvar $ Just $ searchLoop qsearch nid storeResult st | 316 | writeTVar kvar $ Just $ searchLoop qsearch nid storeResult st |
315 | 317 | ||
316 | reportSearchResults :: (Show t, Ord t1, Ord t, Hashable t) => | 318 | reportSearchResults :: (Show t, Ord t1, Ord t, Hashable t) => |
@@ -552,10 +554,10 @@ clientSession s@Session{..} sock cnum h = do | |||
552 | (dtastr,ys) = break isSpace $ dropWhile isSpace xs | 554 | (dtastr,ys) = break isSpace $ dropWhile isSpace xs |
553 | a = Map.lookup method dhtAnnouncables | 555 | a = Map.lookup method dhtAnnouncables |
554 | q = Map.lookup method dhtQuery | 556 | q = Map.lookup method dhtQuery |
555 | doit :: Char -> proxy ni -> Announcer -> AnnounceMethod ni r -> r -> IO () | 557 | doit :: Char -> proxy ni -> Announcer -> AnnounceKey -> AnnounceMethod r -> r -> IO () |
556 | doit '+' _ = schedule | 558 | doit '+' _ = schedule |
557 | doit '-' _ = cancel | 559 | doit '-' _ = cancel |
558 | doit _ _ = \_ _ _ -> hPutClient h "Starting(+) or canceling(-)?" | 560 | doit _ _ = \_ _ _ _ -> hPutClient h "Starting(+) or canceling(-)?" |
559 | matchingResult :: | 561 | matchingResult :: |
560 | ( Typeable sr | 562 | ( Typeable sr |
561 | , Typeable stok | 563 | , Typeable stok |
@@ -573,9 +575,12 @@ clientSession s@Session{..} sock cnum h = do | |||
573 | DHTQuery { qsearch } <- q | 575 | DHTQuery { qsearch } <- q |
574 | (Refl,Refl,nr@Refl) <- matchingResult qsearch announceSendData | 576 | (Refl,Refl,nr@Refl) <- matchingResult qsearch announceSendData |
575 | dta <- either (const Nothing) Just $ announceParseData dtastr | 577 | dta <- either (const Nothing) Just $ announceParseData dtastr |
576 | return $ doit op nr announcer | 578 | return $ do |
577 | (AnnounceMethod qsearch announceSendData) | 579 | akey <- atomically $ packAnnounceKey announcer (method ++ ":" ++ dtastr) |
578 | dta | 580 | doit op nr announcer |
581 | akey | ||
582 | (AnnounceMethod qsearch announceSendData) | ||
583 | dta | ||
579 | fromMaybe (hPutClient h "error.") mameth | 584 | fromMaybe (hPutClient h "error.") mameth |
580 | 585 | ||
581 | ("s", s) | Just dht@DHT{..} <- Map.lookup netname dhts | 586 | ("s", s) | Just dht@DHT{..} <- Map.lookup netname dhts |