Xmpp library

Index:

Functions:

xmpp-connect

xmpp-connect

Synopsis
Opens a xmpp connection.
Usage
(xmpp-connect
  domain
  username
  password
  "connection-listener" => connection_listener
  "incoming-listener" => incoming_listener
  "outgoing-listener" => outgoing_listener
)
Returns
connection_id
Where
  • domain is string: the xmpp domain.
  • username is string: the username registered in domain.
  • password is string: the username password.
  • connection_listener is function[0..1]: a user function that takes 2 arguments: (change_type detail) that will be invoked every time a change in the state of the connection occurs.
  • incoming_listener is function[0..1]: a user function that takes 2 arguments: (participant message) that will be invoked every time a message is received from a participant.
  • outgoing_listener is function[0..1]: a user function that takes 2 arguments: (participant message) that will be invoked every time a message is sent to a participant.
  • connection_id is string: a connection identifier.
Description
This function establishes a connection with the domain server and logs in with the given username and password. If listeners are provided they are registered and kept active until the end of the connection.
Examples
(xmpp-connect
  "suchat.org"
  "brain4it_bot"
  "p229s824k"
  "connection-listener" =>
  (function (st de) (push log (list st de)))
  "incoming-listener" =>
  (function (pa me) (process_msg pa me))
)
"7f71ba03551a4fcc972bf9595ec22a63"
xmpp-disconnect

xmpp-disconnect

Synopsis
Closes a xmpp connection.
Usage
(xmpp-disconnect connection_id)
Returns
closed
Where
  • connection_id is string: a connection identifier.
  • closed is boolean: true if connection was closed of false otherwise.
Description
Closes the connection identified by connection_id. All listeners and resources of this connection are removed or released.
Examples
(xmpp-disconnect
  "7f71ba03551a4fcc972bf9595ec22a63"
)
true
xmpp-send

xmpp-send

Synopsis
Sends a message to a participant.
Usage
(xmpp-send connection_id participant message)
Returns
bytes_sent
Where
  • connection_id is string: a connection identifier.
  • participant is string: the jid (user identifier) of the participant.
  • message is string: the message to send to the participant.
  • bytes_sent is number: the number of bytes sent to the participant.
Description
Sends the given text message to the specified participant and returns the number of bytes sent.
Examples
(xmpp-send conn "realor@suchat.org" "Hello!")
6
Top