diff options
author | James Crayne <jim.crayne@gmail.com> | 2018-06-27 04:51:47 +0000 |
---|---|---|
committer | James Crayne <jim.crayne@gmail.com> | 2018-06-27 04:51:47 +0000 |
commit | b7fa89d90e126df313b3c0289046bada3d108924 (patch) | |
tree | 04c8b171aa08a40153aad258e611183718c72e4a /examples | |
parent | ce5f39de5a3980e5c273e83b98a971368952da3f (diff) |
add sendChatMsg test to testTox
Diffstat (limited to 'examples')
-rw-r--r-- | examples/testTox.hs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/examples/testTox.hs b/examples/testTox.hs index a58c1fa0..5314024f 100644 --- a/examples/testTox.hs +++ b/examples/testTox.hs | |||
@@ -28,6 +28,7 @@ import Network.Tox.Onion.Transport | |||
28 | import Connection | 28 | import Connection |
29 | import qualified Data.HashMap.Strict as HashMap | 29 | import qualified Data.HashMap.Strict as HashMap |
30 | ;import Data.HashMap.Strict (HashMap) | 30 | ;import Data.HashMap.Strict (HashMap) |
31 | import qualified Data.Map.Strict as Map | ||
31 | import Data.Time.Clock.POSIX | 32 | import Data.Time.Clock.POSIX |
32 | import System.Exit | 33 | import System.Exit |
33 | 34 | ||
@@ -125,6 +126,24 @@ main = do | |||
125 | tid <- myThreadId | 126 | tid <- myThreadId |
126 | labelThread tid "testToxLaunch" | 127 | labelThread tid "testToxLaunch" |
127 | void $ netCrypto a_Ct7g5azVcJ8KnvxzbXs9GqeqcjrP7VdZXIC'uHeTlRf a_secret b_public | 128 | void $ netCrypto a_Ct7g5azVcJ8KnvxzbXs9GqeqcjrP7VdZXIC'uHeTlRf a_secret b_public |
129 | dput XUnused "REACHEDREACHEDREACHEDREACHED" | ||
130 | dput XUnused "REACHEDREACHEDREACHEDREACHED" | ||
131 | dput XUnused "REACHEDREACHEDREACHEDREACHED" | ||
132 | threadDelay 1000000 | ||
133 | -- a says "Howdy" | ||
134 | mp_a <- atomically . readTVar $ CH.netCryptoSessionsByKey (toxCryptoSessions a_Ct7g5azVcJ8KnvxzbXs9GqeqcjrP7VdZXIC'uHeTlRf) | ||
135 | case Map.lookup b_public mp_a of | ||
136 | Just [session] -> do | ||
137 | dput XUnused "----------------- HOWDY ---------------" | ||
138 | CH.sendChatMsg (toxCryptoKeys a_Ct7g5azVcJ8KnvxzbXs9GqeqcjrP7VdZXIC'uHeTlRf) session "Howdy" | ||
139 | -- b says "Hey you!" | ||
140 | mp_b <- atomically . readTVar $ CH.netCryptoSessionsByKey (toxCryptoSessions b_OM7znaPMYkTbm'9GcZJAdnDATXmZxZ9fnaSTP3qNCZk) | ||
141 | case Map.lookup a_public mp_b of | ||
142 | Just [session] -> do | ||
143 | dput XUnused "----------------- HEY YOU ---------------" | ||
144 | void $ CH.sendChatMsg (toxCryptoKeys b_OM7znaPMYkTbm'9GcZJAdnDATXmZxZ9fnaSTP3qNCZk) session "Hey you!" | ||
145 | Just xs -> dput XUnused "Unexpectedly b has TOO MANY sesions for a" | ||
146 | Nothing -> dput XUnused "Unexpectedly b has NO session for a" | ||
128 | 147 | ||
129 | putStrLn "Type Enter to quit..." | 148 | putStrLn "Type Enter to quit..." |
130 | getLine | 149 | getLine |