summaryrefslogtreecommitdiff
path: root/Presence
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2013-06-29 20:44:43 -0400
committerjoe <joe@jerkface.net>2013-06-29 20:44:43 -0400
commit6f2ad62dc05913f559b5e2f92e79fdaa73e4db0e (patch)
tree71743ee8e155d273dd8756d73f809305d9558b89 /Presence
parent0c0aa967184b5b39f7944f1b901721ff27126a6c (diff)
more info on unhandled stanza
Diffstat (limited to 'Presence')
-rw-r--r--Presence/XMPP.hs12
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)
21import Control.Concurrent.STM 21import Control.Concurrent.STM
22import Data.Conduit 22import Data.Conduit
23import qualified Data.Conduit.List as CL 23import qualified Data.Conduit.List as CL
24import qualified Data.Conduit.Binary as CB
24import Data.ByteString (ByteString) 25import Data.ByteString (ByteString)
25import qualified Data.ByteString.Char8 as S (pack,putStr,putStrLn) 26import qualified Data.ByteString.Char8 as S (pack,putStr,putStrLn,append)
26import qualified Data.ByteString.Lazy.Char8 as L 27import 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
367prettyPrint prefix xs = 370prettyPrint 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
372toClient :: MonadIO m => TChan Presence -> TChan Commands -> Source m [XML.Event] 374toClient :: MonadIO m => TChan Presence -> TChan Commands -> Source m [XML.Event]
373toClient pchan cmdChan = fix $ \loop -> do 375toClient 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