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.
base64discoidnjidcopy: 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.copyPerform a shallow copy of object.
object: the object to copyfrom_xmlConvert a raw XML string into a structured representation.
string: the string to convertget_helpRetrieves the help information from target.
Returns a table with the following fields:
description: the description of targetparameters: 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 ofhelpPrints 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 ofhexifyConvert binary data into hexadecimal format.
data: the data to convertnew_clientCreates a new client.
Returns a Client object.
jid: The JID to connect aspassphrase: The passphrase to usenew_uuidGenerates a new UUID
sha1Compute the SHA–1 hash of given data
data: the data to hashsleepSleeps for the given time.
milliseconds: the amount of milliseconds to sleepto_xmlConvert a structured element into XML.
element: the element to converttprintPretty-print a table
table: the table to printunhexifyConvert 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_pubsubremove_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_contactAdd a contact to the contact list.
selfjid: 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_connectConnect to the server asynchronously.
This method immediately returns.
selfhost: 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_subscriptionCancel the subscription of a contact.
selfjid: the JID of the contact to cancel the subscription ofconfirm_subscriptionConfirm subscription of a contact.
selfjid: the JID of the contact to confirm the subscription ofconnectConnect to the server.
This method blocks until the connection has been established.
selfhost: 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.disconnectDisconnect from the server
selfeventsReturns an iterator over all events.
This function blocks until timeout is reached (or blocks forever if it is omitted).
selftype: 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_eventCalls f for each event.
selftype: 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_messageCall f for all events of type message.
selftimeout: 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_presenceCall f for all events of type presence.
selftimeout: 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_eventCall f for all events of type pubsub.
selftimeout: 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.getSends a get query.
selftimeout: 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_contactsReturns a table of all the contacts in the contact list.
selfget_disco_itemsSends a get query of type disco_items.
Apart from the options below, all top level elements of disco_items can be passed.
selftimeout: 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_domSends a get query of type dom.
Apart from the options below, all top level elements of dom can be passed.
selftimeout: 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_eventReturns the next event.
selftype: 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_messageGet the next event of type message.
selftype: 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_presenceGet the next event of type presence.
selftype: 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_eventGet the next event of type pubsub.
selftype: 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_versionSends a get query of type software_version.
Apart from the options below, all top level elements of software_version can be passed.
selftimeout: 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_vcardSends a get query of type vcard.
Apart from the options below, all top level elements of vcard can be passed.
selftimeout: 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_xmlSends a get query of type xml.
Apart from the options below, all top level elements of xml can be passed.
selftimeout: 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_connectedChecks whether this client is still connected.
Returns a boolean.
selfjidReturns the JID of this client
selfmessagesReturns an iterator over all events of type message.
selftimeout: 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_eventsProcess all pending events
selfpubsubReturns a PubSub object for communicating with the PubSub service at jid.
selfjid: The JID of the PubSub servicepubsub_eventsReturns an iterator over all events of type pubsub.
selftimeout: 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_pubsubremove_contactRemove a contact from the contact list.
selfjid: the JID of the contact to removesendSends a raw string
selfdata: the string to sendsend_messageSend a message.
selfbody: 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_presenceSend presence.
selfbody: 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)setSends a set query.
selftimeout: 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_nodeSets the caps node of this client
selfnode: The caps node (e.g. ‘http://swift.im/sluift’)set_commandSends a set query of type command.
Apart from the options below, all top level elements of command can be passed.
selftimeout: 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_infoSets the service discovery information for this client
selfdisco_info: A structured representation of the service discovery informationset_optionsSets the connection options of this client.
selfhost: 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_versionSets the published version of this client.
selfos: the OS this client is running onversion: the version identifier of this clientname: the name of the client softwarewait_connectedBlock until the client is connected.
This is useful after an async_connect.
selfPubSub classInterface to communicate with a PubSub service
eventsfor_each_eventget_affiliationsget_default_configurationget_default_subscription_optionsget_next_eventget_subscriptionslist_nodesnodeeventsfor_each_eventget_affiliationsget_default_configurationget_default_subscription_optionsget_next_eventget_subscriptionslist_nodesnodePubSubNode classInterface to communicate with a PubSub node on a service
createdeleteeventsfor_each_eventget_affiliationsget_configurationget_default_subscription_optionsget_itemget_itemsget_next_eventget_owner_affiliationsget_owner_subscriptionsget_subscription_optionsget_subscriptionslist_itemspublishpurgeretractset_configurationset_owner_affiliationssubscribeunsubscribecreatedeleteeventsfor_each_eventget_affiliationsget_configurationget_default_subscription_optionsget_itemget_itemsget_next_eventget_owner_affiliationsget_owner_subscriptionsget_subscription_optionsget_subscriptionslist_itemspublishpurgeretractset_configurationset_owner_affiliationssubscribeunsubscribePubSubRetract 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: FormPubSubEventDisassociate 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: FormUserLocation 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: PubSubEventDisassociateassociate: PubSubEventAssociatePubSubEventSubscription 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: PubSubEventRedirectPubSubCreate classThis table has the following fields:
node: stringconfigure: PubSubConfigurePubSubOwnerPurge 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: Formsubscriptionid: 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: PubSubOptionsPubSubOwnerDelete classThis table has the following fields:
node: stringredirect: PubSubOwnerRedirectPubSubOwnerDefault classThis table has the following fields:
data: FormPubSubSubscriptions 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: PubSubSubscribeOptionssubscription: "none", "pending", "subscribed", or "unconfigured"PubSubEventConfiguration classThis table has the following fields:
node: stringdata: FormDiscoInfo classRepresents disco#info service discovery data.
This table has the following structure:
node: stringidentities: array(table)name: stringcategory: stringtype: stringlanguage: stringfeatures: array(string)