X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fjabber.php;h=3d388bd01dbed13ca1fac68d03a484bb95b280d0;hb=147dd16ab3f1d03a6bee8b3c8bf93170acab4ba9;hp=db043ff72928ffd1f7836bd685b02d5359aec510;hpb=c46f152697b7abfe6a33bec38c6b793e288d85c8;p=quix0rs-gnu-social.git diff --git a/lib/jabber.php b/lib/jabber.php index db043ff729..3d388bd01d 100644 --- a/lib/jabber.php +++ b/lib/jabber.php @@ -40,7 +40,7 @@ function jabber_daemon_address() { 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') ? @@ -57,19 +57,22 @@ function jabber_connect($resource=NULL, $status=NULL, $priority=NULL) { common_config('xmpp', 'debug') ? XMPPHP_Log::LEVEL_VERBOSE : NULL ); - $conn->autoSubscribe(); - $conn->useEncryption(common_config('xmpp', 'encryption')); if (!$conn) { return false; } - $conn->connect(true); # true = persistent connection - if ($conn->isDisconnected()) { + + $conn->autoSubscribe(); + $conn->useEncryption(common_config('xmpp', 'encryption')); + + try { + $conn->connect(true); # true = persistent connection + } catch (XMPPHP_Exception $e) { + common_log(LOG_ERROR, $e->getMessage()); return false; } + $conn->processUntil('session_start'); -# $conn->getRoster(); - $conn->presence($presence, 'available', NULL, 'available', $priority); } return $conn; } @@ -89,6 +92,7 @@ function jabber_send_notice($to, $notice) { $msg = jabber_format_notice($profile, $notice); $entry = jabber_format_entry($profile, $notice); $conn->message($to, $msg, 'chat', NULL, $entry); + $profile->free(); return true; } @@ -119,7 +123,7 @@ function jabber_format_entry($profile, $notice) { $html = "\n\n"; $html .= "
\n"; - $html .= "".$profile->nickname.": "; + $html .= "".$profile->nickname.": "; $html .= ($notice->rendered) ? $notice->rendered : common_render_content($notice->content, $notice); $html .= "\n\n"; $html .= "\n\n"; @@ -128,15 +132,9 @@ function jabber_format_entry($profile, $notice) { $address .= "\n"; $address .= "\n"; - $event = "