pontarius-xmpp-0.1.0.2: An incomplete implementation of RFC 6120 (XMPP: Core)

Safe HaskellNone

Network.Xmpp.Concurrent

Synopsis

Documentation

listenIQChanSource

Arguments

:: IQRequestType

Type of IQs to receive (Get or Set)

-> Text

Namespace of the child element

-> Session 
-> IO (Either (TChan IQRequestTicket) (TChan IQRequestTicket)) 

Retrieves an IQ listener channel. If the namespace/IQRequestType is not already handled, a new TChan is created and returned as a Right value. Otherwise, the already existing channel will be returned wrapped in a Left value. Note that the Left channel might need to be duplicated in order not to interfere with existing consumers.

getStanzaChan :: Session -> IO (TChan Stanza)Source

Get a duplicate of the stanza channel

getMessageChan :: Session -> IO (TChan (Either MessageError Message))Source

Get the inbound stanza channel, duplicates from master if necessary. Please note that once duplicated it will keep filling up, call dropMessageChan to allow it to be garbage collected.

dropMessageChan :: Session -> IO ()Source

Drop the local end of the inbound stanza channel from our context so it can be GC-ed.

pullMessage :: Session -> IO (Either MessageError Message)Source

Read an element from the inbound stanza channel, acquiring a copy of the channel as necessary.

pullPresence :: Session -> IO (Either PresenceError Presence)Source

Read an element from the inbound stanza channel, acquiring a copy of the channel as necessary.

sendStanza :: Stanza -> Session -> IO ()Source

Send a stanza to the server.

forkSession :: Session -> IO SessionSource

Create a forked session object

filterMessages :: (MessageError -> Bool) -> (Message -> Bool) -> Session -> IO (Either MessageError Message)Source

Pulls a message and returns it if the given predicate returns True.

waitForMessage :: (Message -> Bool) -> Session -> IO MessageSource

Pulls a (non-error) message and returns it if the given predicate returns True.

waitForMessageError :: (MessageError -> Bool) -> Session -> IO MessageErrorSource

Pulls an error message and returns it if the given predicate returns True.

waitForPresence :: (Presence -> Bool) -> Session -> IO PresenceSource

Pulls a (non-error) presence and returns it if the given predicate returns True.

withConnection :: XmppConMonad a -> Session -> IO (Either StreamError a)Source

Run an XmppConMonad action in isolation. Reader and writer workers will be temporarily stopped and resumed with the new session details once the action returns. The action will run in the calling thread. Any uncaught exceptions will be interpreted as connection failure.

sendPresence :: Presence -> Session -> IO ()Source

Send a presence stanza.

sendMessage :: Message -> Session -> IO ()Source

Send a message stanza.

modifyHandlers :: (EventHandlers -> EventHandlers) -> Session -> IO ()Source

Executes a function to update the event handlers.

setConnectionClosedHandler :: (StreamError -> Session -> IO ()) -> Session -> IO ()Source

Sets the handler to be executed when the server connection is closed.

runHandler :: (EventHandlers -> IO a) -> Session -> IO aSource

Run an event handler.

endSession :: Session -> IO ()Source

End the current Xmpp session.

closeConnection :: Session -> IO ()Source

Close the connection to the server. Closes the stream (by enforcing a write lock and sending a /stream:stream element), waits (blocks) for three seconds, and then closes the connection.

readWorker :: TChan (Either MessageError Message) -> TChan (Either PresenceError Presence) -> TChan Stanza -> TVar IQHandlers -> TVar EventHandlers -> TMVar XmppConnection -> IO ()Source

handleIQRequest :: TVar IQHandlers -> IQRequest -> STM ()Source

writeWorker :: TChan Stanza -> TMVar (ByteString -> IO Bool) -> IO ()Source

startThreads :: IO (TChan (Either MessageError Message), TChan (Either PresenceError Presence), TChan Stanza, TVar IQHandlers, TChan Stanza, IO (), TMVar (ByteString -> IO Bool), TMVar XmppConnection, ThreadId, TVar EventHandlers)Source

Runs thread in XmppState monad. Returns channel of incoming and outgoing stances, respectively, and an Action to stop the Threads and close the connection.

newSession :: IO SessionSource

Initializes a new XMPP session.

connPersist :: TMVar (ByteString -> IO Bool) -> IO ()Source

Sends a blank space every 30 seconds to keep the connection alive.

sendIQSource

Arguments

:: Maybe Int

Timeout

-> Maybe Jid

Recipient (to)

-> IQRequestType

IQ type (Get or Set)

-> Maybe LangTag

Language tag of the payload (Nothing for default)

-> Element

The IQ body (there has to be exactly one)

-> Session 
-> IO (TMVar IQResponse) 

Sends an IQ, returns a TMVar that will be filled with the first inbound IQ with a matching ID that has type result or error.

sendIQ' :: Maybe Jid -> IQRequestType -> Maybe LangTag -> Element -> Session -> IO IQResponseSource

Like sendIQ, but waits for the answer IQ. Times out after 3 seconds