Browse Source

fixed build errors for EchoClient

master
Jon Kristensen 13 years ago
parent
commit
8338cc6536
  1. 17
      examples/EchoClient.hs
  2. 3
      source/Network/Xmpp.hs

17
examples/EchoClient.hs

@ -36,24 +36,23 @@ resource = Nothing
-- TODO: Incomplete code, needs documentation, etc. -- TODO: Incomplete code, needs documentation, etc.
main :: IO () main :: IO ()
main = do main = do
withNewSession $ do session <- newSession
withConnection $ simpleConnect hostname username password resource withConnection (simpleConnect hostname username password resource) session
sendPresence presenceOnline sendPresence presenceOnline session
echo echo session
return ()
return () return ()
-- Pull message stanzas, verify that they originate from a `full' XMPP -- Pull message stanzas, verify that they originate from a `full' XMPP
-- address, and, if so, `echo' the message back. -- address, and, if so, `echo' the message back.
echo :: Xmpp () echo :: Session -> IO ()
echo = forever $ do echo session = forever $ do
result <- pullMessage result <- pullMessage session
case result of case result of
Right message -> Right message ->
if (isJust $ messageFrom message) && if (isJust $ messageFrom message) &&
(isFull $ fromJust $ messageFrom message) then do (isFull $ fromJust $ messageFrom message) then do
-- TODO: May not set from. -- TODO: May not set from.
sendMessage $ Message Nothing (messageTo message) (messageFrom message) Nothing (messageType message) (messagePayload message) sendMessage (Message Nothing (messageTo message) (messageFrom message) Nothing (messageType message) (messagePayload message)) session
liftIO $ putStrLn "Message echoed!" liftIO $ putStrLn "Message echoed!"
else liftIO $ putStrLn "Message sender is not set or is bare!" else liftIO $ putStrLn "Message sender is not set or is bare!"
Left exception -> liftIO $ putStrLn "Error: " Left exception -> liftIO $ putStrLn "Error: "

3
source/Network/Xmpp.hs

@ -29,7 +29,8 @@
module Network.Xmpp module Network.Xmpp
( -- * Session management ( -- * Session management
newSession Session
, newSession
, withConnection , withConnection
, connect , connect
, simpleConnect , simpleConnect

Loading…
Cancel
Save