Io Reference







Networking   /   Loudmouth   /   Loudmouth





Loudmouth is an async XMPP library written in C. Example usage:
acc := Loudmouth with("user@server.com", "super password") do(
  handleConnect = method(
    "Connected!" println)

  handleMessage = method(msg
    "#{msg from} > #{msg plainBody}" println
    body :=  msg plainBody

    if(body indexOf("#") == 0,
      body = doString(body) asString)

    # This way you can manipulate
    # XML nodes with SGML addon
    XmppChatMessage create\
      setPlainBody(body)\
      setTo(msg from)\
      sendVia(self)

    # or simply send the message (must be a Sequence)
    # (this is obviously faster)
    #self send(msg from, body))
)

acc connect
# Any Io code after this line won't be executed
# (unless called as Loudmouth callback or run in separate thread)
Loudmouth startMainLoop

 
 
 



connect

Connects to the server. Returns self.
disconnect

Disconnects from server and returns true if it succeeds.
handleAuthenticated

Slot called upon successful authentication.
handleAuthenticationFailure

Slot called if username/password combinaton is wrong.
handleConnect

Slot called once connection is established.
handleConnectFailure

Slot called when server is not reachable.
handleDisconnect

Slot called upon closing the connection with the server.
handleMessage(xmppMessage)

Slot called when a message arrives via XMPP stream. xmppMessage is a LoudmouthMessage object.
handleSslFailure

Slot called if SSL-related problems arrive. Method should return true if it wishes to make a connection without SSL, false otherwise.
isConnected

isSslSupported

registerAccount(server, username, password)

Registers a new account at XMPP server. Returns true or false.
send(toJid, message)

Sends a message (Sequence) to provided JID (Sequence). Returns true or false.
sendRaw(body)

Sends raw text over XMPP stream. Returns true if no errors occur.
setPresence(presence[, statusMessage])

Sets availability/presence and status message.
setStatusMessage(statusMessage)

Sets status message.
startMainLoop

Starts GMainLoop. Should be called after a connection is established with the server.
status

Returns status connection. Possible return values are:
  • Loudmouth types CLOSED
  • Loudmouth types OPENING
  • Loudmouth types OPEN
  • Loudmouth types AUTHENTICATING
  • Loudmouth types AUTHENTICATED
stopMainLoop

types

Object containing status codes and message types.


  Loudmouth with("username@server.com", "password") do(
    handleConnect = method(
      self setPresence(Loudmouth types AVAILABLE), "Drinking lemonade...")
  )
  
with(jid, password)

Creates a new Loudmouth clone with server details provided in jid.