diff options
author | joe <joe@jerkface.net> | 2013-06-29 20:44:43 -0400 |
---|---|---|
committer | joe <joe@jerkface.net> | 2013-06-29 20:44:43 -0400 |
commit | 6f2ad62dc05913f559b5e2f92e79fdaa73e4db0e (patch) | |
tree | 71743ee8e155d273dd8756d73f809305d9558b89 | |
parent | 0c0aa967184b5b39f7944f1b901721ff27126a6c (diff) |
more info on unhandled stanza
-rw-r--r-- | Presence/XMPP.hs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/Presence/XMPP.hs b/Presence/XMPP.hs index 5435c913..36d9bf74 100644 --- a/Presence/XMPP.hs +++ b/Presence/XMPP.hs | |||
@@ -21,8 +21,9 @@ import Network.BSD (PortNumber) | |||
21 | import Control.Concurrent.STM | 21 | import Control.Concurrent.STM |
22 | import Data.Conduit | 22 | import Data.Conduit |
23 | import qualified Data.Conduit.List as CL | 23 | import qualified Data.Conduit.List as CL |
24 | import qualified Data.Conduit.Binary as CB | ||
24 | import Data.ByteString (ByteString) | 25 | import Data.ByteString (ByteString) |
25 | import qualified Data.ByteString.Char8 as S (pack,putStr,putStrLn) | 26 | import qualified Data.ByteString.Char8 as S (pack,putStr,putStrLn,append) |
26 | import qualified Data.ByteString.Lazy.Char8 as L | 27 | import qualified Data.ByteString.Lazy.Char8 as L |
27 | ( putStrLn | 28 | ( putStrLn |
28 | , fromChunks | 29 | , fromChunks |
@@ -352,7 +353,9 @@ fromClient session cmdChan = doNestingXML $ do | |||
352 | whenJust nextElement $ \stanza -> do | 353 | whenJust nextElement $ \stanza -> do |
353 | stanza_lvl <- nesting | 354 | stanza_lvl <- nesting |
354 | 355 | ||
355 | let unhandledStanza = liftIO $ putStrLn ("ignoring stanza: "++show stanza) | 356 | let unhandledStanza = do |
357 | mb <- lift . runMaybeT $ gatherElement stanza Seq.empty | ||
358 | withJust mb $ \xs -> prettyPrint "C: " (toList xs) | ||
356 | case () of | 359 | case () of |
357 | _ | stanza `isIQOf` iqTypeSet -> handleIQSet session cmdChan stanza | 360 | _ | stanza `isIQOf` iqTypeSet -> handleIQSet session cmdChan stanza |
358 | _ | otherwise -> unhandledStanza | 361 | _ | otherwise -> unhandledStanza |
@@ -366,8 +369,7 @@ fromClient session cmdChan = doNestingXML $ do | |||
366 | 369 | ||
367 | prettyPrint prefix xs = | 370 | prettyPrint prefix xs = |
368 | liftIO $ do | 371 | liftIO $ do |
369 | S.putStrLn prefix | 372 | CL.sourceList xs $= renderBytes (def { rsPretty=True }) =$= CB.lines $$ CL.mapM_ (S.putStrLn . (prefix `S.append`)) |
370 | CL.sourceList xs $= renderBytes (def { rsPretty=True }) $$ CL.mapM_ S.putStr | ||
371 | 373 | ||
372 | toClient :: MonadIO m => TChan Presence -> TChan Commands -> Source m [XML.Event] | 374 | toClient :: MonadIO m => TChan Presence -> TChan Commands -> Source m [XML.Event] |
373 | toClient pchan cmdChan = fix $ \loop -> do | 375 | toClient pchan cmdChan = fix $ \loop -> do |
@@ -376,7 +378,7 @@ toClient pchan cmdChan = fix $ \loop -> do | |||
376 | (fmap Right $ readTChan cmdChan) | 378 | (fmap Right $ readTChan cmdChan) |
377 | case event of | 379 | case event of |
378 | Right QuitThread -> return () | 380 | Right QuitThread -> return () |
379 | Right (Send xs) -> yield xs >> prettyPrint "client-out: " xs >> loop | 381 | Right (Send xs) -> yield xs >> prettyPrint ">C: " xs >> loop |
380 | Left presence -> do | 382 | Left presence -> do |
381 | xs <- liftIO $ xmlifyPresenceForClient presence | 383 | xs <- liftIO $ xmlifyPresenceForClient presence |
382 | yield xs | 384 | yield xs |