You are here

function messaging_xmpp_connect in Messaging 6.2

Same name and namespace in other branches
  1. 6.4 messaging_xmpp/messaging_xmpp.module \messaging_xmpp_connect()
  2. 6.3 messaging_xmpp/messaging_xmpp.module \messaging_xmpp_connect()

Get a XMPP connection using XMPPFramework and messaging jid

1 call to messaging_xmpp_connect()
messaging_xmpp_send_msg in messaging_xmpp/messaging_xmpp.module
Send message via the xmppframework

File

messaging_xmpp/messaging_xmpp.module, line 208
XMPP Messsaging. Messaging method plug-in

Code

function messaging_xmpp_connect() {
  static $conn, $tried = FALSE;
  if ($conn) {

    // If we already have a connection for this page request, use it
    return $conn;
  }
  elseif ($tried) {

    // Or if the connection failed, do not try again
    return FALSE;
  }
  else {
    $tried = TRUE;

    // We need to set presence, the messages may not be delivered if not.
    if ($conn = xmppframework_get_server_connection()) {
      xmppframework_set_presence(NULL, $type = 'available', $show = 'available', $status = 'Available', $conn);
    }
    return $conn;
  }
}