return common_config('xmpp', 'user') . '@' . common_config('xmpp', 'server');
}
-function jabber_connect($resource=NULL, $status=NULL, $priority=NULL) {
+function jabber_connect($resource=NULL) {
static $conn = NULL;
if (!$conn) {
$conn = new XMPPHP_XMPP(common_config('xmpp', 'host') ?
return false;
}
$conn->processUntil('session_start');
-# $conn->getRoster();
- $conn->presence($presence, 'available', NULL, 'available', $priority);
}
return $conn;
}
return true;
}
-function jabber_send_presence($status, $show='available', $to=Null) {
+function jabber_send_presence($status, $show='available', $to=NULL,
+ $type = 'available', $priority=NULL)
+{
$conn = jabber_connect();
if (!$conn) {
return false;
}
- $conn->presence($status, $show, $to);
+ $conn->presence($status, $show, $to, $type, $priority);
return true;
}
function start() {
$this->log(LOG_INFO, "INITIALIZE");
# Low priority; we don't want to receive messages
- $this->conn = jabber_connect($this->_id, NULL, -1);
- $this->conn->addEventHandler('message', 'forward_message', $this);
+ $this->conn = jabber_connect($this->_id);
+ if ($this->conn) {
+ $this->conn->addEventHandler('message', 'forward_message', $this);
+ jabber_send_presence("Send me a message to post an notice", 'dnd', NULL, 'available', -1);
+ }
return !is_null($this->conn);
}
function start() {
# Low priority; we don't want to receive messages
$this->log(LOG_INFO, "INITIALIZE");
- $this->conn = jabber_connect($this->_id, NULL, -1);
- $this->conn->addEventHandler('message', 'forward_message', $this);
+ $this->conn = jabber_connect($this->_id);
+ if ($this->conn) {
+ $this->conn->addEventHandler('message', 'forward_message', $this);
+ jabber_send_presence("Send me a message to post an notice", 'dnd', NULL, 'available', -1);
+ }
return !is_null($this->conn);
}
$this->log(LOG_INFO, "Connecting to $connect_to on port $this->port");
- $this->conn = jabber_connect($this->resource, "Send me a message to post a notice", 100);
+ $this->conn = jabber_connect($this->resource);
if (!$this->conn) {
return false;
}
+ jabber_send_presence("Send me a message to post a notice", 'available',
+ NULL, 'available', 100);
return !$this->conn->isDisconnected();
}
function start() {
$this->log(LOG_INFO, "INITIALIZE");
# Low priority; we don't want to receive messages
- $this->conn = jabber_connect($this->_id, NULL, -1);
- $this->conn->addEventHandler('message', 'forward_message', $this);
+ $this->conn = jabber_connect($this->_id);
+ if ($this->conn) {
+ $this->conn->addEventHandler('message', 'forward_message', $this);
+ jabber_send_presence("Send me a message to post an notice", 'dnd', NULL, 'available', -1);
+ }
return !is_null($this->conn);
}