Browse Source

Update the tutorial and the example for the `session' changes

master
Jon Kristensen 13 years ago
parent
commit
5c11a02061
  1. 10
      README.md
  2. 5
      examples/echoclient/Main.hs

10
README.md

@ -2,8 +2,7 @@ Welcome to Pontarius XMPP!
========================== ==========================
Pontarius XMPP is an active work in progress to build a Haskell XMPP library Pontarius XMPP is an active work in progress to build a Haskell XMPP library
that implements the client capabilities of [RFC 6120 ("XMPP that implements the client capabilities of [RFC 6120](http://tools.ietf.org/html/rfc6120).
Core")](http://tools.ietf.org/html/rfc6120).
Getting started Getting started
--------------- ---------------
@ -34,7 +33,7 @@ When this is done, a <code>Session</code> object can be acquired by calling
result <- session result <- session
"example.com" "example.com"
def def
(Just ([scramSha1 "user" Nothing "Password"], Nothing)) (Just ([scramSha1 "username" Nothing "password"], Nothing))
_Tip:_ Note that the first parameter actually is a Text value. Import _Tip:_ Note that the first parameter actually is a Text value. Import
<code>Data.Text</code> and use the OverloadedStrings LANGUAGE pragma. <code>Data.Text</code> and use the OverloadedStrings LANGUAGE pragma.
@ -47,14 +46,13 @@ with TLS, authenticate, establish a concurrent interface for interacting with
the stream, and return the <code>Session</code> object. the stream, and return the <code>Session</code> object.
The return type of <code>session</code> is <code>IO (Either XmppFailure The return type of <code>session</code> is <code>IO (Either XmppFailure
(Session, Maybe AuthFailure))</code>. As <code>XmppFailure</code> is an Session)</code>. As <code>XmppFailure</code> is an
<code>Control.Monad.Error</code> instance, you can utilize the <code>Control.Monad.Error</code> instance, you can utilize the
<code>ErrorT</code> monad transformer for error handling. A more simple way of <code>ErrorT</code> monad transformer for error handling. A more simple way of
doing it could be doing something like this: doing it could be doing something like this:
sess <- case result of sess <- case result of
Right (s, Nothing) -> return s Right s -> return s
Right (_s, e) -> error $ "AuthFailure: " ++ (show e)
Left e -> error $ "XmppFailure: " ++ (show e) Left e -> error $ "XmppFailure: " ++ (show e)
Next, let us set our status to Online. Next, let us set our status to Online.

5
examples/echoclient/Main.hs

@ -21,10 +21,9 @@ main = do
result <- session result <- session
"example.com" "example.com"
def def
(Just ([scramSha1 "user" Nothing "Password"], Nothing)) (Just ([scramSha1 "username" Nothing "password"], Nothing))
sess <- case result of sess <- case result of
Right (s, Nothing) -> return s Right s -> return s
Right (_s, e) -> error $ "AuthFailure: " ++ (show e)
Left e -> error $ "XmppFailure: " ++ (show e) Left e -> error $ "XmppFailure: " ++ (show e)
sendPresence (Presence Nothing Nothing Nothing Nothing Nothing []) sess sendPresence (Presence Nothing Nothing Nothing Nothing Nothing []) sess
forever $ do forever $ do

Loading…
Cancel
Save