summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/dhtd.hs29
1 files changed, 29 insertions, 0 deletions
diff --git a/examples/dhtd.hs b/examples/dhtd.hs
index ce6cc8f7..6ef4539f 100644
--- a/examples/dhtd.hs
+++ b/examples/dhtd.hs
@@ -702,6 +702,35 @@ clientSession s@Session{..} sock cnum h = do
702 else do 702 else do
703 rows <- sessionsReport 703 rows <- sessionsReport
704 hPutClient h (showColumns (headers:rows)) 704 hPutClient h (showColumns (headers:rows))
705 -- session <N> set key val
706 ("session",s) | (idStr,"set",unstripped) <- twoWords s
707 , (key,val,unstripped2) <- twoWords unstripped
708 , let setmap = [("ncRequestInterval", \s x -> writeTVar (Tox.ncRequestInterval s) x)
709 ,("ncAliveInterval", \s x -> writeTVar (Tox.ncAliveInterval s) x)
710 ,("ncIdleEvent", \s x -> writeTVar (Tox.ncIdleEvent s) x)
711 ,("ncTimeOut", \s x -> writeTVar (Tox.ncTimeOut s) x)
712 ]
713 , Just stmFunc <- Data.List.lookup key setmap
714 -> cmd0 $ do
715 lrSession <- strToSession idStr
716 case lrSession of
717 Left s -> hPutClient h s
718 Right session -> do
719 case readMaybe val of
720 Just (x::Int) -> do
721 atomically (stmFunc session x)
722 hPutClient h $ "Session " ++ idStr ++ ": " ++ key ++ " = " ++ val
723 _ ->
724 hPutClient h $ "Invalid " ++ key ++ " value: " ++ val
725
726 -- report error when setting invalid keys
727 ("session",s) | (idStr,"set",unstripped) <- twoWords s
728 , (key,val,unstripped2) <- twoWords unstripped
729 -> cmd0 $ do
730 lrSession <- strToSession idStr
731 case lrSession of
732 Left s -> hPutClient h s
733 Right session -> hPutClient h $ "What is " ++ key ++ "?"
705 -- session <N> tail 734 -- session <N> tail
706 -- show context (latest lossless messages) 735 -- show context (latest lossless messages)
707 ("session", s) | (idStr,tailcmd,unstripped) <- twoWords s 736 ("session", s) | (idStr,tailcmd,unstripped) <- twoWords s