Safe Haskell | None |
---|
- data Session
- listenIQChan :: IQRequestType -> Text -> Session -> IO (Either (TChan IQRequestTicket) (TChan IQRequestTicket))
- getStanzaChan :: Session -> IO (TChan Stanza)
- getMessageChan :: Session -> IO (TChan (Either MessageError Message))
- getPresenceChan :: Session -> IO (TChan (Either PresenceError Presence))
- dropMessageChan :: Session -> IO ()
- dropPresenceChan :: Session -> IO ()
- pullMessage :: Session -> IO (Either MessageError Message)
- pullPresence :: Session -> IO (Either PresenceError Presence)
- sendStanza :: Stanza -> Session -> IO ()
- forkSession :: Session -> IO Session
- filterMessages :: (MessageError -> Bool) -> (Message -> Bool) -> Session -> IO (Either MessageError Message)
- waitForMessage :: (Message -> Bool) -> Session -> IO Message
- waitForMessageError :: (MessageError -> Bool) -> Session -> IO MessageError
- waitForPresence :: (Presence -> Bool) -> Session -> IO Presence
- withConnection :: XmppConMonad a -> Session -> IO (Either StreamError a)
- sendPresence :: Presence -> Session -> IO ()
- sendMessage :: Message -> Session -> IO ()
- modifyHandlers :: (EventHandlers -> EventHandlers) -> Session -> IO ()
- setConnectionClosedHandler :: (StreamError -> Session -> IO ()) -> Session -> IO ()
- runHandler :: (EventHandlers -> IO a) -> Session -> IO a
- endSession :: Session -> IO ()
- closeConnection :: Session -> IO ()
- readWorker :: TChan (Either MessageError Message) -> TChan (Either PresenceError Presence) -> TChan Stanza -> TVar IQHandlers -> TVar EventHandlers -> TMVar XmppConnection -> IO ()
- handleIQRequest :: TVar IQHandlers -> IQRequest -> STM ()
- handleIQResponse :: TVar IQHandlers -> Either IQError IQResult -> STM ()
- writeWorker :: TChan Stanza -> TMVar (ByteString -> IO Bool) -> IO ()
- 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)
- newSession :: IO Session
- connPersist :: TMVar (ByteString -> IO Bool) -> IO ()
- sendIQ :: Maybe Int -> Maybe Jid -> IQRequestType -> Maybe LangTag -> Element -> Session -> IO (TMVar IQResponse)
- sendIQ' :: Maybe Jid -> IQRequestType -> Maybe LangTag -> Element -> Session -> IO IQResponse
- answerIQ :: IQRequestTicket -> Either StanzaError (Maybe Element) -> Session -> IO Bool
Documentation
:: IQRequestType | Type of IQs to receive ( |
-> 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.
getPresenceChan :: Session -> IO (TChan (Either PresenceError Presence))Source
Analogous to getMessageChan
.
dropMessageChan :: Session -> IO ()Source
Drop the local end of the inbound stanza channel from our context so it can be GC-ed.
dropPresenceChan :: Session -> IO ()Source
Analogous to dropMessageChan
.
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.
:: Maybe Int | Timeout |
-> Maybe Jid | Recipient (to) |
-> IQRequestType | IQ type ( |
-> Maybe LangTag | Language tag of the payload ( |
-> 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
.