Browse Source

fix debugging messaages in Network.Xmpp.Sasl and write inbound TCP messages to debug logger

master
Philipp Balzarek 13 years ago
parent
commit
fea7e3f7ac
  1. 12
      source/Network/Xmpp/Sasl.hs
  2. 9
      source/Network/Xmpp/Stream.hs

12
source/Network/Xmpp/Sasl.hs

@ -101,19 +101,17 @@ xmppBind rsrc c = runErrorT $ do
answer <- ErrorT $ pushIQ "bind" Nothing Set Nothing (bindBody rsrc) c answer <- ErrorT $ pushIQ "bind" Nothing Set Nothing (bindBody rsrc) c
case answer of case answer of
Right IQResult{iqResultPayload = Just b} -> do Right IQResult{iqResultPayload = Just b} -> do
lift $ debugM "Pontarius.XMPP" "xmppBind: IQ result received; unpickling JID..." lift $ debugM "Pontarius.Xmpp" "xmppBind: IQ result received; unpickling JID..."
let jid = unpickleElem xpJid b let jid = unpickleElem xpJid b
case jid of case jid of
Right jid' -> do Right jid' -> do
lift $ infoM "Pontarius.XMPP" $ "Bound JID: " ++ show jid' lift $ infoM "Pontarius.Xmpp" $ "Bound JID: " ++ show jid'
_ <- lift $ withStream ( do _ <- lift $ withStream ( do modify $ \s ->
modify $ \s -> s{streamJid = Just jid'})
s{streamJid = Just jid'}
return $ Right ())
c c
return jid' return jid'
_ -> do _ -> do
lift $ errorM "Pontarius.XMPP" lift $ errorM "Pontarius.Xmpp"
$ "xmppBind: JID could not be unpickled from: " $ "xmppBind: JID could not be unpickled from: "
++ show b ++ show b
throwError $ XmppOtherFailure throwError $ XmppOtherFailure

9
source/Network/Xmpp/Stream.hs

@ -29,6 +29,7 @@ import Data.Maybe
import Data.Ord import Data.Ord
import Data.Text (Text) import Data.Text (Text)
import qualified Data.Text as Text import qualified Data.Text as Text
import qualified Data.Text.Encoding as Text
import Data.Void (Void) import Data.Void (Void)
import Data.XML.Pickle import Data.XML.Pickle
import Data.XML.Types import Data.XML.Types
@ -236,7 +237,11 @@ restartStream = do
bs <- liftIO (rd 4096) bs <- liftIO (rd 4096)
if BS.null bs if BS.null bs
then return () then return ()
else yield bs >> loopRead rd else do
liftIO $ debugM "Pontarius.Xmpp" $ "in: " ++
(Text.unpack . Text.decodeUtf8 $ bs)
yield bs
loopRead rd
-- Reads the (partial) stream:stream and the server features from the stream. -- Reads the (partial) stream:stream and the server features from the stream.
-- Returns the (unvalidated) stream attributes, the unparsed element, or -- Returns the (unvalidated) stream attributes, the unparsed element, or
@ -739,7 +744,7 @@ elements = do
compressNodes $ NodeContent (ContentText $ x `Text.append` y) : z compressNodes $ NodeContent (ContentText $ x `Text.append` y) : z
compressNodes (x:xs) = x : compressNodes xs compressNodes (x:xs) = x : compressNodes xs
withStream :: StateT StreamState IO (Either XmppFailure c) -> Stream -> IO (Either XmppFailure c) withStream :: StateT StreamState IO a -> Stream -> IO a
withStream action (Stream stream) = Ex.bracketOnError withStream action (Stream stream) = Ex.bracketOnError
(atomically $ takeTMVar stream ) (atomically $ takeTMVar stream )
(atomically . putTMVar stream) (atomically . putTMVar stream)

Loading…
Cancel
Save