- data JID = JID {}
- jid :: Maybe String -> String -> Maybe String -> JID
- jidIsFull :: JID -> Bool
- jidIsBare :: JID -> Bool
- stringToJID :: String -> Maybe JID
- jidToString :: JID -> String
- replyToChallenge1 :: String -> String -> String -> String -> String -> Either String Challenge1Error
- type Certificate = String
- data MonadIO m => ClientHandler s m = ClientHandler {
- messageReceived :: Maybe (Message -> StateT s m Bool)
- presenceReceived :: Maybe (Presence -> StateT s m Bool)
- iqReceived :: Maybe (IQ -> StateT s m Bool)
- sessionTerminated :: Maybe (TerminationReason -> StateT s m ())
- class ClientState s m where
- putSession :: s -> Session s m -> s
- data ConnectResult
- = ConnectSuccess StreamProperties StreamFeatures (Maybe Resource)
- | ConnectOpenStreamFailure
- | ConnectSecureWithTLSFailure
- | ConnectAuthenticateFailure
- type HostName = String
- type Password = String
- type PortNumber = Integer
- type Resource = String
- data Session s m
- data TerminationReason
- type UserName = String
- sendIQ :: MonadIO m => Session s m -> IQ -> Maybe (IQ -> StateT s m Bool) -> Maybe (Timeout, StateT s m ()) -> Maybe (StreamError -> StateT s m ()) -> StateT s m ()
- sendPresence :: MonadIO m => Session s m -> Presence -> Maybe (Presence -> StateT s m Bool) -> Maybe (Timeout, StateT s m ()) -> Maybe (StreamError -> StateT s m ()) -> StateT s m ()
- sendMessage :: MonadIO m => Session s m -> Message -> Maybe (Message -> StateT s m Bool) -> Maybe (Timeout, StateT s m ()) -> Maybe (StreamError -> StateT s m ()) -> StateT s m ()
- connect :: MonadIO m => Session s m -> HostName -> PortNumber -> Maybe (Certificate, Certificate -> Bool) -> Maybe (UserName, Password, Maybe Resource) -> (ConnectResult -> StateT s m ()) -> StateT s m ()
- openStream :: MonadIO m => Session s m -> HostName -> PortNumber -> (OpenStreamResult -> StateT s m ()) -> StateT s m ()
- secureWithTLS :: MonadIO m => Session s m -> Certificate -> (Certificate -> Bool) -> (SecureWithTLSResult -> StateT s m ()) -> StateT s m ()
- authenticate :: MonadIO m => Session s m -> UserName -> Password -> Maybe Resource -> (AuthenticateResult -> StateT s m ()) -> StateT s m ()
- session :: (MonadIO m, ClientState s m) => s -> [ClientHandler s m] -> StateT s m () -> m ()
- data OpenStreamResult
- = OpenStreamSuccess StreamProperties StreamFeatures
- | OpenStreamFailure
- data SecureWithTLSResult
- = SecureWithTLSSuccess StreamProperties StreamFeatures
- | SecureWithTLSFailure
- data AuthenticateResult
- = AuthenticateSuccess StreamProperties StreamFeatures Resource
- | AuthenticateFailure
- data StanzaID = SID String
- type From = JID
- type To = JID
- type XMLLang = String
- data Stanza = Stanza {}
- data MessageType
- data Message
- = Message { }
- | MessageError { }
- message :: Maybe StanzaID -> Maybe From -> Maybe To -> Maybe XMLLang -> MessageType -> [Element] -> Message
- data PresenceType
- = Subscribe
- | Subscribed
- | Unsubscribe
- | Unsubscribed
- | Probe
- | Available
- | Unavailable
- data Presence
- presence :: Maybe StanzaID -> Maybe From -> Maybe To -> Maybe XMLLang -> PresenceType -> [Element] -> Presence
- data IQ
- iqGet :: Maybe StanzaID -> Maybe From -> Maybe To -> Maybe XMLLang -> Element -> IQ
- iqSet :: Maybe StanzaID -> Maybe From -> Maybe To -> Maybe XMLLang -> Element -> IQ
- iqResult :: Maybe StanzaID -> Maybe From -> Maybe To -> Maybe XMLLang -> Maybe Element -> IQ
- iqStanza :: IQ -> Stanza
- iqPayloadNamespace :: IQ -> Maybe String
- iqPayload :: IQ -> Maybe Element
- getId :: IQ -> StanzaID
- iqAck :: StanzaID -> To -> IQ
- injectAction :: MonadIO m => Session s m -> Maybe (StateT s m Bool) -> StateT s m () -> StateT s m ()
- elementToString :: Maybe Element -> String
- elementsToString :: [Element] -> String
- getID :: IO String
- getID_ :: Int -> IO String
Documentation
jid :: Maybe String -> String -> Maybe String -> JIDSource
Simple function to construct a JID. We will add validation to this function in a later release.
jidIsFull :: JID -> BoolSource
JIDs are written in the format of `node@server/resource'. A JID without a
resource identifier (i.e. a JID in the form of server
or `node@server')
is called a `bare JID'. A JID with a resource identifier is called `full
JID'. This function returns True if the JID is full
and False otherwise.
jidIsBare :: JID -> BoolSource
JIDs are written in the format of `node@server/resource'. A JID without a
resource identifier (i.e. a JID in the form of server
or `node@server')
is called a `bare JID'. A JID with a resource identifier is called `full
JID'. This function returns True if the JID is bare
and False otherwise.
stringToJID :: String -> Maybe JIDSource
Converts a (JID) String to a JID record.
jidToString :: JID -> StringSource
Converts a JID to a String.
replyToChallenge1 :: String -> String -> String -> String -> String -> Either String Challenge1ErrorSource
type Certificate = StringSource
data MonadIO m => ClientHandler s m Source
A client typically needs one or more ClientHandler
objects to interact
with Pontarius XMPP. Each client handler may provide four callback
functions; the first three callbacks deals with received stanzas, and the
last one is used when the session is terminated.
These stanza functions takes the current client state and an object containing the details of the stanza in question. The boolean returned along with the possibly updated state signals whether or not the message should be blocked to client handlerss further down the stack. For example, an XEP-0030: Service Discovery handler may choose to hide disco#info requests to handlers above it in the stack.
The sessionTerminated
callback function takes a TerminationReason
value
along with the state and will be sent to all client handlers.
ClientHandler | |
|
class ClientState s m whereSource
putSession :: s -> Session s m -> sSource
data ConnectResult Source
ConnectSuccess StreamProperties StreamFeatures (Maybe Resource) | |
ConnectOpenStreamFailure | |
ConnectSecureWithTLSFailure | |
ConnectAuthenticateFailure |
type PortNumber = IntegerSource
Readability type for port number Integers.
The Session
object is used by clients when interacting with Pontarius
XMPP. It holds information needed by Pontarius XMPP; its content is not
accessible from the client.
data TerminationReason Source
TerminationReason
contains information on why the XMPP session was
terminated.
sendIQ :: MonadIO m => Session s m -> IQ -> Maybe (IQ -> StateT s m Bool) -> Maybe (Timeout, StateT s m ()) -> Maybe (StreamError -> StateT s m ()) -> StateT s m ()Source
sendPresence :: MonadIO m => Session s m -> Presence -> Maybe (Presence -> StateT s m Bool) -> Maybe (Timeout, StateT s m ()) -> Maybe (StreamError -> StateT s m ()) -> StateT s m ()Source
sendMessage :: MonadIO m => Session s m -> Message -> Maybe (Message -> StateT s m Bool) -> Maybe (Timeout, StateT s m ()) -> Maybe (StreamError -> StateT s m ()) -> StateT s m ()Source
connect :: MonadIO m => Session s m -> HostName -> PortNumber -> Maybe (Certificate, Certificate -> Bool) -> Maybe (UserName, Password, Maybe Resource) -> (ConnectResult -> StateT s m ()) -> StateT s m ()Source
openStream :: MonadIO m => Session s m -> HostName -> PortNumber -> (OpenStreamResult -> StateT s m ()) -> StateT s m ()Source
secureWithTLS :: MonadIO m => Session s m -> Certificate -> (Certificate -> Bool) -> (SecureWithTLSResult -> StateT s m ()) -> StateT s m ()Source
authenticate :: MonadIO m => Session s m -> UserName -> Password -> Maybe Resource -> (AuthenticateResult -> StateT s m ()) -> StateT s m ()Source
session :: (MonadIO m, ClientState s m) => s -> [ClientHandler s m] -> StateT s m () -> m ()Source
Creates an XMPP session. Blocks the current thread. The first parameter,
s
, is an arbitrary state that is defined by the client. This is the
initial state, and it will be passed to the client (handlers) as XMPP
events are emitted. The second parameter is the list of ClientHandler
s;
this is a way to provide a layered system of XMPP event handlers. For
example, a client may have a dedicated handler to manage messages,
implement a spam protection system, etc. Messages are piped through these
handlers one by one, and any handler may block the message from being sent
to the next handler(s) above in the stack. The third argument is a callback
function that will be called when the session has been initialized, and
this function should be used by the client to store the Session object in
its state.
data OpenStreamResult Source
OpenStreamSuccess StreamProperties StreamFeatures | |
OpenStreamFailure |
data SecureWithTLSResult Source
SecureWithTLSSuccess StreamProperties StreamFeatures | |
SecureWithTLSFailure |
data AuthenticateResult Source
AuthenticateSuccess StreamProperties StreamFeatures Resource | |
AuthenticateFailure |
data MessageType Source
message :: Maybe StanzaID -> Maybe From -> Maybe To -> Maybe XMLLang -> MessageType -> [Element] -> MessageSource
data PresenceType Source
Subscribe | Sender wants to subscribe to presence |
Subscribed | Sender has approved the subscription |
Unsubscribe | Sender is unsubscribing from presence |
Unsubscribed | Sender has denied or cancelled a subscription |
Probe | Sender requests current presence; should only be used by servers PresenceError | -- ^ Processing or delivery of previously sent presence stanza failed |
Available | |
Unavailable |
Presence stanzas are used to express an entity's network availability.
presence :: Maybe StanzaID -> Maybe From -> Maybe To -> Maybe XMLLang -> PresenceType -> [Element] -> PresenceSource
injectAction :: MonadIO m => Session s m -> Maybe (StateT s m Bool) -> StateT s m () -> StateT s m ()Source
elementsToString :: [Element] -> StringSource