aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2023-01-02 20:39:15 +0100
committerMario Vavti <mario@mariovavti.com>2023-01-02 20:39:15 +0100
commitd8c94c2003bfb53626171c86ffbbd860680e86ec (patch)
tree8b49d508f4f7645e2c1977679c3b1a571a5ba481
parent0e71bfe2224b8fc54a58aff80894e1f22294bd6e (diff)
parent0ae402e6247907fa7b2afbdaeca59410da56693a (diff)
downloadvolse-hubzilla-d8c94c2003bfb53626171c86ffbbd860680e86ec.tar.gz
volse-hubzilla-d8c94c2003bfb53626171c86ffbbd860680e86ec.tar.bz2
volse-hubzilla-d8c94c2003bfb53626171c86ffbbd860680e86ec.zip
Merge branch 'dev' of https://framagit.org/hubzilla/core into dev
-rw-r--r--Zotlabs/Module/Sse.php32
-rw-r--r--boot.php2
2 files changed, 25 insertions, 9 deletions
diff --git a/Zotlabs/Module/Sse.php b/Zotlabs/Module/Sse.php
index f87a19821..8b46dcafd 100644
--- a/Zotlabs/Module/Sse.php
+++ b/Zotlabs/Module/Sse.php
@@ -50,7 +50,7 @@ class Sse extends Controller {
self::$vnotify = get_pconfig(self::$uid, 'system', 'vnotify');
}
- $sleep_seconds = 3;
+ $sleep = 1000000; // microseconds
self::$sse_enabled = get_config('system', 'sse_enabled', 0);
@@ -63,17 +63,24 @@ class Sse extends Controller {
header("Connection: keep-alive");
header("X-Accel-Buffering: no");
- while(true) {
+ $i = 0;
- if(! self::$sse_id) {
+ while(true) {
- // Update chat presence indication
+ // reset counter for updating chatpresence about every minute
+ if (($i * $sleep)/60 > 1000000) {
+ $i = 0;
+ }
+ if(!self::$sse_id && $i === 0) {
+ // Update chat presence indication about once per minute
$r = q("select cp_id, cp_room from chatpresence where cp_xchan = '%s' and cp_client = '%s' and cp_room = 0 limit 1",
dbesc(self::$ob_hash),
dbesc($_SERVER['REMOTE_ADDR'])
);
+
$basic_presence = false;
+
if($r) {
$basic_presence = true;
q("update chatpresence set cp_last = '%s' where cp_id = %d",
@@ -81,7 +88,8 @@ class Sse extends Controller {
intval($r[0]['cp_id'])
);
}
- if(! $basic_presence) {
+
+ if(!$basic_presence) {
q("insert into chatpresence ( cp_xchan, cp_last, cp_status, cp_client)
values( '%s', '%s', '%s', '%s' ) ",
dbesc(self::$ob_hash),
@@ -94,9 +102,14 @@ class Sse extends Controller {
XConfig::Load(self::$ob_hash);
- $result = XConfig::Get(self::$ob_hash, 'sse', 'notifications', []);
+ $result = [];
$lock = XConfig::Get(self::$ob_hash, 'sse', 'lock');
+ if (!$lock) {
+ $result = XConfig::Get(self::$ob_hash, 'sse', 'notifications', []);
+ }
+
+
// We do not have the local_channel in the addon.
// Reset pubs here if the app is not installed.
if (self::$uid && (!(self::$vnotify & VNOTIFY_PUBS) || !Apps::system_app_installed(self::$uid, 'Public Stream'))) {
@@ -105,7 +118,7 @@ class Sse extends Controller {
}
}
- if($result && !$lock) {
+ if($result) {
echo "event: notifications\n";
echo 'data: ' . json_encode($result);
echo "\n\n";
@@ -121,6 +134,7 @@ class Sse extends Controller {
if(ob_get_length() > 0)
ob_end_flush();
+
flush();
if(connection_status() != CONNECTION_NORMAL || connection_aborted()) {
@@ -129,7 +143,9 @@ class Sse extends Controller {
break;
}
- sleep($sleep_seconds);
+ $i++;
+
+ usleep($sleep);
}
diff --git a/boot.php b/boot.php
index 843d2e4b1..b02dad9d6 100644
--- a/boot.php
+++ b/boot.php
@@ -60,7 +60,7 @@ require_once('include/bbcode.php');
require_once('include/items.php');
define('PLATFORM_NAME', 'hubzilla');
-define('STD_VERSION', '7.9.15');
+define('STD_VERSION', '7.9.16');
define('ZOT_REVISION', '6.0');
define('DB_UPDATE_VERSION', 1255);