X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fjabber.php;h=bd7d6b7074d38acbeb713a124d67178812eebfbc;hb=dd4c0ebaa8717012e8bae58088c1a2760152bc41;hp=3e74cbbb82d8601541a9ef35d5f8712ea1cfb266;hpb=c6c3cd40f6304b49f5d4841e9999641a183e987b;p=quix0rs-gnu-social.git
diff --git a/lib/jabber.php b/lib/jabber.php
index 3e74cbbb82..bd7d6b7074 100644
--- a/lib/jabber.php
+++ b/lib/jabber.php
@@ -57,16 +57,21 @@ function jabber_connect($resource=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');
}
return $conn;
@@ -87,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;
}
@@ -126,16 +132,9 @@ function jabber_format_entry($profile, $notice) {
$address .= "
\n";
$address .= "\n";
- $event = "\n";
- $event .= "\n";
- $event .= " \n";
- $event .= "\n";
- $event .= "\n";
- # FIXME: include the pubsub event, too.
-# return $html . $entry . $address;
- return $entry . $address;
-# return $entry . "\n" . $event;
+ # FIXME: include a pubsub event, too.
+
+ return $html . $entry . $address;
}
function jabber_send_message($to, $body, $type='chat', $subject=NULL) {
@@ -206,6 +205,9 @@ function jabber_broadcast_notice($notice) {
$msg = jabber_format_notice($profile, $notice);
$entry = jabber_format_entry($profile, $notice);
+ $profile->free();
+ unset($profile);
+
$sent_to = array();
$conn = jabber_connect();
@@ -223,9 +225,12 @@ function jabber_broadcast_notice($notice) {
'Sending reply notice ' . $notice->id . ' to ' . $user->jabber,
__FILE__);
$conn->message($user->jabber, $msg, 'chat', NULL, $entry);
+ $conn->processTime(0);
$sent_to[$user->id] = 1;
}
+ $user->free();
+
# Now, get users subscribed to this profile
$user = new User();
@@ -241,9 +246,13 @@ function jabber_broadcast_notice($notice) {
'Sending notice ' . $notice->id . ' to ' . $user->jabber,
__FILE__);
$conn->message($user->jabber, $msg, 'chat', NULL, $entry);
+ # To keep the incoming queue from filling up, we service it after each send.
+ $conn->processTime(0);
}
}
+ $user->free();
+
return true;
}
@@ -277,7 +286,9 @@ function jabber_public_notice($notice) {
'Sending notice ' . $notice->id . ' to public listener ' . $address,
__FILE__);
$conn->message($address, $msg, 'chat', NULL, $entry);
+ $conn->processTime(0);
}
+ $profile->free();
}
return true;