Network.Protocol.XMPP

network-protocol-xmpp-0.4.8: Client library for the XMPP protocol.

Safe Haskell | None
Language | Haskell98

Network.Protocol.XMPP

Contents

- JIDs
- Stanzas
- The XMPP monad
  - Resuming sessions

Synopsis

- data JID = JID {
  - jidNode :: Maybe Node
  - jidDomain :: Domain
  - jidResource :: Maybe Resource
  }
- data Node
- data Domain
- data Resource
- strNode :: Node -> Text
- strDomain :: Domain -> Text
- strResource :: Resource -> Text
- parseJID :: Text -> Maybe JID
- formatJID :: JID -> Text
- class Stanza a where
- data ReceivedStanza
  - = ReceivedMessage Message
  - | ReceivedPresence Presence
  - | ReceivedIQ IQ
- data Message = Message {
  - messageType :: MessageType
  - messageTo :: Maybe JID
  - messageFrom :: Maybe JID
  - messageID :: Maybe Text
  - messageLang :: Maybe Text
  - messagePayloads :: [Element]
  }
- data Presence = Presence {
  - presenceType :: PresenceType
  - presenceTo :: Maybe JID
  - presenceFrom :: Maybe JID
  - presenceID :: Maybe Text
  - presenceLang :: Maybe Text
  - presencePayloads :: [Element]
  }
- data IQ = IQ {
  - iqType :: IQType
  - iqTo :: Maybe JID
  - iqFrom :: Maybe JID
  - iqID :: Maybe Text
  - iqLang :: Maybe Text
  - iqPayload :: Maybe Element
  }
- data MessageType
  - = MessageNormal
  - | MessageChat
  - | MessageGroupChat
  - | MessageHeadline
  - | MessageError
- data PresenceType
  - = PresenceAvailable
  - | PresenceUnavailable
  - | PresenceSubscribe
  - | PresenceSubscribed
  - | PresenceUnsubscribe
  - | PresenceUnsubscribed
  - | PresenceProbe
  - | PresenceError
- data IQType
  - = IQGet
  - | IQSet
  - | IQResult
  - | IQError
- emptyMessage :: MessageType -> Message
- emptyPresence :: PresenceType -> Presence
- emptyIQ :: IQType -> IQ
- data XMPP a
- data Server = Server {
  - serverJID :: JID
  - serverHostname :: HostName
  - serverPort :: PortID
  }
- data Error
  - = AuthenticationFailure Element
  - | AuthenticationError Text
  - | InvalidStanza Element
  - | InvalidBindResult ReceivedStanza
  - | TransportError Text
  - | NoComponentStreamID
- runClient :: Server -> JID -> Text -> Text -> XMPP a -> IO (Either Error a)
- runComponent :: Server -> Text -> XMPP a -> IO (Either Error a)
- putStanza :: Stanza a => a -> XMPP ()
- getStanza :: XMPP ReceivedStanza
- bindJID :: JID -> XMPP JID
- data Session
- getSession :: XMPP Session
- sessionIsSecure :: XMPP Bool
- runXMPP :: Session -> XMPP a -> IO (Either Error a)

# JIDs

data JID #

Constructors

JID |
Fields jidNode :: Maybe Node jidDomain :: Domain jidResource :: Maybe Resource

Instances

Eq JID # |
Methods (==) :: JID -> JID -> Bool # (/=) :: JID -> JID -> Bool #
Show JID # |
Methods showsPrec :: Int -> JID -> ShowS # show :: JID -> String # showList :: [JID] -> ShowS #
IsString JID # |
Methods fromString :: String -> JID #

data Node #

Instances

Eq Node # |
Methods (==) :: Node -> Node -> Bool # (/=) :: Node -> Node -> Bool #
Show Node # |
Methods showsPrec :: Int -> Node -> ShowS # show :: Node -> String # showList :: [Node] -> ShowS #

data Domain #

Instances

Eq Domain # |
Methods (==) :: Domain -> Domain -> Bool # (/=) :: Domain -> Domain -> Bool #
Show Domain # |
Methods showsPrec :: Int -> Domain -> ShowS # show :: Domain -> String # showList :: [Domain] -> ShowS #

data Resource #

Instances

Eq Resource # |
Methods (==) :: Resource -> Resource -> Bool # (/=) :: Resource -> Resource -> Bool #
Show Resource # |
Methods showsPrec :: Int -> Resource -> ShowS # show :: Resource -> String # showList :: [Resource] -> ShowS #

strNode :: Node -> Text #

strDomain :: Domain -> Text #

strResource :: Resource -> Text #

parseJID :: Text -> Maybe JID #

formatJID :: JID -> Text #

# Stanzas

class Stanza a where #

Minimal complete definition

stanzaTo, stanzaFrom, stanzaID, stanzaLang, stanzaPayloads, stanzaToElement

Methods

stanzaTo :: a -> Maybe JID #

stanzaFrom :: a -> Maybe JID #

stanzaID :: a -> Maybe Text #

stanzaLang :: a -> Maybe Text #

stanzaPayloads :: a -> [Element] #

Instances

Stanza IQ # |
Methods stanzaTo :: IQ -> Maybe JID # stanzaFrom :: IQ -> Maybe JID # stanzaID :: IQ -> Maybe Text # stanzaLang :: IQ -> Maybe Text # stanzaPayloads :: IQ -> [Element] # stanzaToElement :: IQ -> Element
Stanza Presence # |
Methods stanzaTo :: Presence -> Maybe JID # stanzaFrom :: Presence -> Maybe JID # stanzaID :: Presence -> Maybe Text # stanzaLang :: Presence -> Maybe Text # stanzaPayloads :: Presence -> [Element] # stanzaToElement :: Presence -> Element
Stanza Message # |
Methods stanzaTo :: Message -> Maybe JID # stanzaFrom :: Message -> Maybe JID # stanzaID :: Message -> Maybe Text # stanzaLang :: Message -> Maybe Text # stanzaPayloads :: Message -> [Element] # stanzaToElement :: Message -> Element

data ReceivedStanza #

Constructors

ReceivedMessage Message |
ReceivedPresence Presence |
ReceivedIQ IQ |

Instances

Show ReceivedStanza # |
Methods showsPrec :: Int -> ReceivedStanza -> ShowS # show :: ReceivedStanza -> String # showList :: [ReceivedStanza] -> ShowS #

data Message #

Constructors

Message |
Fields messageType :: MessageType messageTo :: Maybe JID messageFrom :: Maybe JID messageID :: Maybe Text messageLang :: Maybe Text messagePayloads :: [Element]

Instances

Show Message # |
Methods showsPrec :: Int -> Message -> ShowS # show :: Message -> String # showList :: [Message] -> ShowS #
Stanza Message # |
Methods stanzaTo :: Message -> Maybe JID # stanzaFrom :: Message -> Maybe JID # stanzaID :: Message -> Maybe Text # stanzaLang :: Message -> Maybe Text # stanzaPayloads :: Message -> [Element] # stanzaToElement :: Message -> Element

data Presence #

Constructors

Presence |
Fields presenceType :: PresenceType presenceTo :: Maybe JID presenceFrom :: Maybe JID presenceID :: Maybe Text presenceLang :: Maybe Text presencePayloads :: [Element]

Instances

Show Presence # |
Methods showsPrec :: Int -> Presence -> ShowS # show :: Presence -> String # showList :: [Presence] -> ShowS #
Stanza Presence # |
Methods stanzaTo :: Presence -> Maybe JID # stanzaFrom :: Presence -> Maybe JID # stanzaID :: Presence -> Maybe Text # stanzaLang :: Presence -> Maybe Text # stanzaPayloads :: Presence -> [Element] # stanzaToElement :: Presence -> Element

data IQ #

Constructors

IQ |
Fields iqType :: IQType iqTo :: Maybe JID iqFrom :: Maybe JID iqID :: Maybe Text iqLang :: Maybe Text iqPayload :: Maybe Element

Instances

Show IQ # |
Methods showsPrec :: Int -> IQ -> ShowS # show :: IQ -> String # showList :: [IQ] -> ShowS #
Stanza IQ # |
Methods stanzaTo :: IQ -> Maybe JID # stanzaFrom :: IQ -> Maybe JID # stanzaID :: IQ -> Maybe Text # stanzaLang :: IQ -> Maybe Text # stanzaPayloads :: IQ -> [Element] # stanzaToElement :: IQ -> Element

data MessageType #

Constructors

MessageNormal |
MessageChat |
MessageGroupChat |
MessageHeadline |
MessageError |

Instances

Eq MessageType # |
Methods (==) :: MessageType -> MessageType -> Bool # (/=) :: MessageType -> MessageType -> Bool #
Show MessageType # |
Methods showsPrec :: Int -> MessageType -> ShowS # show :: MessageType -> String # showList :: [MessageType] -> ShowS #

data PresenceType #

Constructors

PresenceAvailable |
PresenceUnavailable |
PresenceSubscribe |
PresenceSubscribed |
PresenceUnsubscribe |
PresenceUnsubscribed |
PresenceProbe |
PresenceError |

Instances

Eq PresenceType # |
Methods (==) :: PresenceType -> PresenceType -> Bool # (/=) :: PresenceType -> PresenceType -> Bool #
Show PresenceType # |
Methods showsPrec :: Int -> PresenceType -> ShowS # show :: PresenceType -> String # showList :: [PresenceType] -> ShowS #

data IQType #

Constructors

IQGet |
IQSet |
IQResult |
IQError |

Instances

Eq IQType # |
Methods (==) :: IQType -> IQType -> Bool # (/=) :: IQType -> IQType -> Bool #
Show IQType # |
Methods showsPrec :: Int -> IQType -> ShowS # show :: IQType -> String # showList :: [IQType] -> ShowS #

emptyMessage :: MessageType -> Message #

emptyPresence :: PresenceType -> Presence #

emptyIQ :: IQType -> IQ #

# The XMPP monad

data XMPP a #

Instances

Monad XMPP # |
Methods (>>=) :: XMPP a -> (a -> XMPP b) -> XMPP b # (>>) :: XMPP a -> XMPP b -> XMPP b # return :: a -> XMPP a # fail :: String -> XMPP a #
Functor XMPP # |
Methods fmap :: (a -> b) -> XMPP a -> XMPP b # (<$) :: a -> XMPP b -> XMPP a #
MonadFix XMPP # |
Methods mfix :: (a -> XMPP a) -> XMPP a #
Applicative XMPP # |
Methods pure :: a -> XMPP a # (<*>) :: XMPP (a -> b) -> XMPP a -> XMPP b # (*>) :: XMPP a -> XMPP b -> XMPP b # (<*) :: XMPP a -> XMPP b -> XMPP a #
MonadIO XMPP # |
Methods liftIO :: IO a -> XMPP a #
MonadError XMPP # |
Associated Types type ErrorType (XMPP :: * -> *) :: * # Methods throwError :: ErrorType XMPP -> XMPP a # catchError :: XMPP a -> (ErrorType XMPP -> XMPP a) -> XMPP a #
type ErrorType XMPP # |
type ErrorType XMPP = Error

data Server #

Constructors

Server |
Fields serverJID :: JID serverHostname :: HostName serverPort :: PortID

data Error #

Constructors

AuthenticationFailure Element | The remote host refused the specified authentication credentials. The included XML element is the error value that the server provided. It may contain additional information about why authentication failed.
AuthenticationError Text | There was an error while authenticating with the remote host.
InvalidStanza Element | An unrecognized or malformed `Stanza` was received from the remote host.
InvalidBindResult ReceivedStanza | The remote host sent an invalid reply to a resource bind request.
TransportError Text | There was an error with the underlying transport.
NoComponentStreamID | The remote host did not send a stream ID when accepting a component connection.

Instances

Show Error # |
Methods showsPrec :: Int -> Error -> ShowS # show :: Error -> String # showList :: [Error] -> ShowS #

runClient #

Arguments

:: Server |
-> JID | Client JID
-> Text | Username
-> Text | Password
-> XMPP a |
-> IO (Either Error a) |

runComponent #

Arguments

:: Server |
-> Text | Server secret
-> XMPP a |
-> IO (Either Error a) |

putStanza :: Stanza a => a -> XMPP () #

getStanza :: XMPP ReceivedStanza #

bindJID :: JID -> XMPP JID #

Send a `<bind>` message for the given `JID`, returning the server's reply. In most cases the reply will be the same as the input. However, if the input has no `Resource`, the returned `JID` will contain a generated `Resource`.

Clients must bind a `JID` before sending any `Stanza`s.

## Resuming sessions

data Session #

getSession :: XMPP Session #

sessionIsSecure :: XMPP Bool #

runXMPP :: Session -> XMPP a -> IO (Either Error a) #