This document describes the API of the sluift
module.
The entry points of Sluift are in the sluift
module, described below.
sluift
moduleThis module provides methods for XMPP communication.
The main entry point of this module is the new_client
method, which creates a
new client for communicating with an XMPP server.
base64
disco
idn
jid
copy
: Perform a shallow copy of object
.from_xml
: Convert a raw XML string into a structured representation.get_help
: Retrieves the help information from target
.help
: Prints the help of target
.hexify
: Convert binary data into hexadecimal format.new_client
: Creates a new client.new_uuid
: Generates a new UUIDsha1
: Compute the SHA–1 hash of given datasleep
: Sleeps for the given time.to_xml
: Convert a structured element into XML.tprint
: Pretty-print a tableunhexify
: Convert hexadecimal data into binary data.copy
Perform a shallow copy of object
.
object
: the object to copyfrom_xml
Convert a raw XML string into a structured representation.
string
: the string to convertget_help
Retrieves the help information from target
.
Returns a table with the following fields:
description
: the description of target
parameters
: an array of parameters of target
represented as tables with name
and description
fields.options
: an array of options (named parameters) of target
represented as tables with name
and
description
fields.methods
: an array of methodsfields
: an array of fieldstarget
: The target to retrieve help ofhelp
Prints the help of target
.
target
can be any object. When target
is a string, prints the help of the class with
the given name.
target
: The target to retrieve help ofhexify
Convert binary data into hexadecimal format.
data
: the data to convertnew_client
Creates a new client.
Returns a Client
object.
jid
: The JID to connect aspassphrase
: The passphrase to usenew_uuid
Generates a new UUID
sha1
Compute the SHA–1 hash of given data
data
: the data to hashsleep
Sleeps for the given time.
milliseconds
: the amount of milliseconds to sleepto_xml
Convert a structured element into XML.
element
: the element to converttprint
Pretty-print a table
table
: the table to printunhexify
Convert hexadecimal data into binary data.
data
: the data in hexadecimal formatClient
classClient interface
add_contact
: Add a contact to the contact list.async_connect
: Connect to the server asynchronously.cancel_subscription
: Cancel the subscription of a contact.confirm_subscription
: Confirm subscription of a contact.connect
: Connect to the server.disconnect
: Disconnect from the serverevents
: Returns an iterator over all events.for_each_event
: Calls f
for each event.for_each_message
: Call f
for all events of type message
.for_each_presence
: Call f
for all events of type presence
.for_each_pubsub_event
: Call f
for all events of type pubsub
.get
: Sends a get
query.get_contacts
: Returns a table of all the contacts in the contact list.get_disco_items
: Sends a get
query of type disco_items
.get_dom
: Sends a get
query of type dom
.get_next_event
: Returns the next event.get_next_message
: Get the next event of type message
.get_next_presence
: Get the next event of type presence
.get_next_pubsub_event
: Get the next event of type pubsub
.get_software_version
: Sends a get
query of type software_version
.get_vcard
: Sends a get
query of type vcard
.get_xml
: Sends a get
query of type xml
.is_connected
: Checks whether this client is still connected.jid
: Returns the JID of this clientmessages
: Returns an iterator over all events of type message
.process_events
: Process all pending eventspubsub
: Returns a PubSub
object for communicating with the PubSub service at jid
.pubsub_events
: Returns an iterator over all events of type pubsub
.query_pubsub
remove_contact
: Remove a contact from the contact list.send
: Sends a raw stringsend_message
: Send a message.send_presence
: Send presence.set
: Sends a set
query.set_caps_node
: Sets the caps node of this clientset_command
: Sends a set
query of type command
.set_disco_info
: Sets the service discovery information for this clientset_options
: Sets the connection options of this client.set_version
: Sets the published version of this client.wait_connected
: Block until the client is connected.add_contact
Add a contact to the contact list.
self
jid
: The JID of the contact to addname
: The name to use in the contact listgroups
: An array of group names to add the contact toasync_connect
Connect to the server asynchronously.
This method immediately returns.
self
host
: The host to connect to. When omitted, is determined by resolving the client JID.port
: The port to connect to. When omitted, is determined by resolving the client JID.cancel_subscription
Cancel the subscription of a contact.
self
jid
: the JID of the contact to cancel the subscription ofconfirm_subscription
Confirm subscription of a contact.
self
jid
: the JID of the contact to confirm the subscription ofconnect
Connect to the server.
This method blocks until the connection has been established.
self
host
: The host to connect to. When omitted, is determined by resolving the client JID.port
: The port to connect to. When omitted, is determined by resolving the client JID.disconnect
Disconnect from the server
self
events
Returns an iterator over all events.
This function blocks until timeout
is reached (or blocks forever if it is omitted).
self
type
: The type of event to return (message
, presence
, pubsub
). When omitted, all event types are returned.timeout
: The amount of time to wait for events.if
: A function to filter events. When this function, called with the event as a parameter, returns true, the event will be returnedfor_each_event
Calls f
for each event.
self
type
: The type of event to return (message
, presence
, pubsub
). When omitted, all event types are returned.timeout
: The amount of time to wait for events.if
: A function to filter events. When this function, called with the event as a parameter, returns true, the event will be returnedf
: The functor to call with each event. Required.for_each_message
Call f
for all events of type message
.
self
timeout
: The amount of time to wait for events.if
: A function to filter events. When this function, called with the event as a parameter, returns true, the event will be returnedf
: The functor to call with each event. Required.for_each_presence
Call f
for all events of type presence
.
self
timeout
: The amount of time to wait for events.if
: A function to filter events. When this function, called with the event as a parameter, returns true, the event will be returnedf
: The functor to call with each event. Required.for_each_pubsub_event
Call f
for all events of type pubsub
.
self
timeout
: The amount of time to wait for events.if
: A function to filter events. When this function, called with the event as a parameter, returns true, the event will be returnedf
: The functor to call with each event. Required.get
Sends a get
query.
self
timeout
: The amount of time to wait for the query to finishto
: The JID of the target to send the query toquery
: The query to sendget_contacts
Returns a table of all the contacts in the contact list.
self
get_disco_items
Sends a get
query of type disco_items
.
Apart from the options below, all top level elements of disco_items
can be passed.
self
timeout
: The amount of time to wait for the query to finishto
: The JID of the target to send the query toquery
: The query to sendget_dom
Sends a get
query of type dom
.
Apart from the options below, all top level elements of dom
can be passed.
self
timeout
: The amount of time to wait for the query to finishto
: The JID of the target to send the query toquery
: The query to sendget_next_event
Returns the next event.
self
type
: The type of event to return (message
, presence
, pubsub
). When omitted, all event types are returned.timeout
: The amount of time to wait for events.if
: A function to filter events. When this function, called with the event as a parameter, returns true, the event will be returnedget_next_message
Get the next event of type message
.
self
type
: The type of event to return (message
, presence
, pubsub
). When omitted, all event types are returned.timeout
: The amount of time to wait for events.if
: A function to filter events. When this function, called with the event as a parameter, returns true, the event will be returnedget_next_presence
Get the next event of type presence
.
self
type
: The type of event to return (message
, presence
, pubsub
). When omitted, all event types are returned.timeout
: The amount of time to wait for events.if
: A function to filter events. When this function, called with the event as a parameter, returns true, the event will be returnedget_next_pubsub_event
Get the next event of type pubsub
.
self
type
: The type of event to return (message
, presence
, pubsub
). When omitted, all event types are returned.timeout
: The amount of time to wait for events.if
: A function to filter events. When this function, called with the event as a parameter, returns true, the event will be returnedget_software_version
Sends a get
query of type software_version
.
Apart from the options below, all top level elements of software_version
can be passed.
self
timeout
: The amount of time to wait for the query to finishto
: The JID of the target to send the query toquery
: The query to sendget_vcard
Sends a get
query of type vcard
.
Apart from the options below, all top level elements of vcard
can be passed.
self
timeout
: The amount of time to wait for the query to finishto
: The JID of the target to send the query toquery
: The query to sendget_xml
Sends a get
query of type xml
.
Apart from the options below, all top level elements of xml
can be passed.
self
timeout
: The amount of time to wait for the query to finishto
: The JID of the target to send the query toquery
: The query to sendis_connected
Checks whether this client is still connected.
Returns a boolean.
self
jid
Returns the JID of this client
self
messages
Returns an iterator over all events of type message
.
self
timeout
: The amount of time to wait for events.if
: A function to filter events. When this function, called with the event as a parameter, returns true, the event will be returnedf
: The functor to call with each event. Required.process_events
Process all pending events
self
pubsub
Returns a PubSub
object for communicating with the PubSub service at jid
.
self
jid
: The JID of the PubSub servicepubsub_events
Returns an iterator over all events of type pubsub
.
self
timeout
: The amount of time to wait for events.if
: A function to filter events. When this function, called with the event as a parameter, returns true, the event will be returnedf
: The functor to call with each event. Required.query_pubsub
remove_contact
Remove a contact from the contact list.
self
jid
: the JID of the contact to removesend
Sends a raw string
self
data
: the string to sendsend_message
Send a message.
self
body
: the body of the message. Can alternatively be specified using the body
optiontype
: the type of message to send (normal
, chat
, error
, groupchat
, headline
)to
: the JID to send the message tobody
: the body of the messagesend_presence
Send presence.
self
body
: the text of the presence. Can alternatively be specified using the status
optionstatus
: the text of the presencepriority
: the priority of the presenceto
: the JID to send the message totype
: the type of message to send (available
, error
, probe
, subscribe
, subscribed
, unavailable
, unsubscribe
, unsubscribed
)set
Sends a set
query.
self
timeout
: The amount of time to wait for the query to finish.to
: The JID of the target to send the query toquery
: The query to send.set_caps_node
Sets the caps node of this client
self
node
: The caps node (e.g. ‘http://swift.im/sluift’)set_command
Sends a set
query of type command
.
Apart from the options below, all top level elements of command
can be passed.
self
timeout
: The amount of time to wait for the query to finishto
: The JID of the target to send the query toquery
: The query to sendset_disco_info
Sets the service discovery information for this client
self
disco_info
: A structured representation of the service discovery informationset_options
Sets the connection options of this client.
self
host
: The host to connect to. When omitted, is determined from resolving the JID domain.port
: The port to connect to. When omitted, is determined from resolving the JID domain.allow_plain_without_tls
: Allow PLAIN authentication without a TLS encrypted connectioncompress
: Use stream compression when availableack
: Request acknowledgementsbosh_url
: Connect using the specified BOSH URLtls
: Use TLS when availableset_version
Sets the published version of this client.
self
os
: the OS this client is running onversion
: the version identifier of this clientname
: the name of the client softwarewait_connected
Block until the client is connected.
This is useful after an async_connect
.
self
PubSub
classInterface to communicate with a PubSub service
events
for_each_event
get_affiliations
get_default_configuration
get_default_subscription_options
get_next_event
get_subscriptions
list_nodes
node
events
for_each_event
get_affiliations
get_default_configuration
get_default_subscription_options
get_next_event
get_subscriptions
list_nodes
node
PubSubNode
classInterface to communicate with a PubSub node on a service
create
delete
events
for_each_event
get_affiliations
get_configuration
get_default_subscription_options
get_item
get_items
get_next_event
get_owner_affiliations
get_owner_subscriptions
get_subscription_options
get_subscriptions
list_items
publish
purge
retract
set_configuration
set_owner_affiliations
subscribe
unsubscribe
create
delete
events
for_each_event
get_affiliations
get_configuration
get_default_subscription_options
get_item
get_items
get_next_event
get_owner_affiliations
get_owner_subscriptions
get_subscription_options
get_subscriptions
list_items
publish
purge
retract
set_configuration
set_owner_affiliations
subscribe
unsubscribe
PubSubRetract
classThis table has the following fields:
node
: stringitems
: array<PubSubItem
>notify
: booleanPubSubAffiliations
classThis table has the following fields:
node
: string (Optional)affiliations
: array<PubSubAffiliation
>PubSubPublish
classThis table has the following fields:
node
: stringitems
: array<PubSubItem
>PubSubItems
classThis table has the following fields:
node
: stringitems
: array<PubSubItem
>maximum_items
: number (Optional)subscriptionid
: string (Optional)PubSubOwnerRedirect
classThis table has the following fields:
uri
: stringPubSubEventRedirect
classThis table has the following fields:
uri
: stringPubSubConfigure
classThis table has the following fields:
data
: Form
PubSubEventDisassociate
classThis table has the following fields:
node
: stringPubSubOwnerAffiliations
classThis table has the following fields:
node
: stringaffiliations
: array<PubSubOwnerAffiliation
>PubSubOwnerConfigure
classThis table has the following fields:
node
: string (Optional)data
: Form
UserLocation
classThis table has the following fields:
area
: string (Optional)altitude
: float
(Optional)locality
: string (Optional)latitude
: float
(Optional)accuracy
: float
(Optional)description
: string (Optional)country_code
: string (Optional)timestamp
: datetime (string) (Optional)floor
: string (Optional)building
: string (Optional)room
: string (Optional)country
: string (Optional)region
: string (Optional)uri
: string (Optional)longitude
: float
(Optional)error
: float
(Optional)postal_code
: string (Optional)bearing
: float
(Optional)text
: string (Optional)datum
: string (Optional)street
: string (Optional)speed
: float
(Optional)PubSubSubscribeOptions
classThis table has the following fields:
required
: booleanPubSubOwnerSubscriptions
classThis table has the following fields:
node
: stringsubscriptions
: array<PubSubOwnerSubscription
>PubSubDefault
classThis table has the following fields:
node
: string (Optional)type
: "none"
, "collection"
, or "leaf"
PubSubEventCollection
classThis table has the following fields:
node
: string (Optional)disassociate
: PubSubEventDisassociate
associate
: PubSubEventAssociate
PubSubEventSubscription
classThis table has the following fields:
node
: stringjid
: jid (string)subscription
: "none"
, "pending"
, "subscribed"
, or "unconfigured"
subscriptionid
: string (Optional)expiry
: datetime (string)PubSubEventRetract
classThis table has the following fields:
id
: stringPubSubItem
classThis table has the following fields:
data
: array<element (table)>id
: stringPubSubUnsubscribe
classThis table has the following fields:
node
: string (Optional)jid
: jid (string)subscriptionid
: string (Optional)PubSubEventDelete
classThis table has the following fields:
node
: stringredirects
: PubSubEventRedirect
PubSubCreate
classThis table has the following fields:
node
: stringconfigure
: PubSubConfigure
PubSubOwnerPurge
classThis table has the following fields:
node
: stringPubSubEventItems
classThis table has the following fields:
node
: stringitems
: array<PubSubEventItem
>retracts
: array<PubSubEventRetract
>PubSubOptions
classThis table has the following fields:
node
: stringjid
: jid (string)data
: Form
subscriptionid
: string (Optional)PubSubEventItem
classThis table has the following fields:
node
: string (Optional)publisher
: string (Optional)data
: array<element (table)>id
: string (Optional)PubSubOwnerSubscription
classThis table has the following fields:
jid
: jid (string)subscription
: "none"
, "pending"
, "subscribed"
, or "unconfigured"
PubSubOwnerAffiliation
classThis table has the following fields:
jid
: jid (string)type
: "none"
, "member"
, "outcast"
, "owner"
, "publisher"
, or "publish_only"
PubSubEventPurge
classThis table has the following fields:
node
: stringPubSubAffiliation
classThis table has the following fields:
node
: stringtype
: "none"
, "member"
, "outcast"
, "owner"
, "publisher"
, or "publish_only"
PubSubSubscribe
classThis table has the following fields:
node
: string (Optional)jid
: jid (string)options
: PubSubOptions
PubSubOwnerDelete
classThis table has the following fields:
node
: stringredirect
: PubSubOwnerRedirect
PubSubOwnerDefault
classThis table has the following fields:
data
: Form
PubSubSubscriptions
classThis table has the following fields:
node
: string (Optional)subscriptions
: array<PubSubSubscription
>PubSubEventAssociate
classThis table has the following fields:
node
: stringPubSubSubscription
classThis table has the following fields:
node
: string (Optional)subscriptionid
: string (Optional)jid
: jid (string)options
: PubSubSubscribeOptions
subscription
: "none"
, "pending"
, "subscribed"
, or "unconfigured"
PubSubEventConfiguration
classThis table has the following fields:
node
: stringdata
: Form
DiscoInfo
classRepresents disco#info
service discovery data.
This table has the following structure:
node
: stringidentities
: array(table)name
: stringcategory
: stringtype
: stringlanguage
: stringfeatures
: array(string)