Browse Source

XEP-0410: MUC Self-Ping, add timeout ping support (when the connection is lost and the pong is never sent)

pull/1373/head
Timothée Jaussoin 12 months ago
parent
commit
93dc031aef
  1. 1
      CHANGELOG.md
  2. 12
      src/Movim/ChatroomPings.php
  3. 4
      src/Moxl/Xec/Action/Ping/Room.php

1
CHANGELOG.md

@ -20,6 +20,7 @@ v0.28.1 (master)
* Add Brief/Article tabs in the Publish widget and load the form using Ajax
* Improve Posts ticket layout
* Fix Contacts invitation handling and notification counter
* XEP-0410: MUC Self-Ping, add timeout ping support (when the connection is lost and the pong is never sent)
v0.28
---------------------------

12
src/Movim/ChatroomPings.php

@ -7,6 +7,7 @@
namespace Movim;
use Moxl\Xec\Action\Ping\Room;
use App\Widgets\Rooms\Rooms as WidgetRooms;
/**
* Handling XEP-0410: MUC Self-Ping (Schrödinger's Chat) pings and timeouts
@ -15,7 +16,9 @@ class ChatroomPings
{
protected static $instance;
private $_chatrooms = [];
private $_timeout = 5 * 60;
private $_chatroomsTimeout = [];
private $_pingIn = 5 * 60;
private $_pongTimeout = 5 * 60 + 10;
public static function getInstance()
{
@ -32,7 +35,7 @@ class ChatroomPings
$this->clear($from);
$this->_chatrooms[$from] = $loop->addTimer($this->_timeout, function () use ($from) {
$this->_chatrooms[$from] = $loop->addTimer($this->_pingIn, function () use ($from) {
$presence = \App\User::me()->session->conferences()
->where('conference', $from)
->first()?->presence;
@ -44,6 +47,10 @@ class ChatroomPings
->request();
}
});
$this->_chatroomsTimeout[$from] = $loop->addTimer($this->_pongTimeout, function () use ($from) {
(new WidgetRooms())->ajaxExit($from);
});
}
public function clear(string $from)
@ -52,6 +59,7 @@ class ChatroomPings
if (array_key_exists($from, $this->_chatrooms)) {
$loop->cancelTimer($this->_chatrooms[$from]);
$loop->cancelTimer($this->_chatroomsTimeout[$from]);
}
}
}

4
src/Moxl/Xec/Action/Ping/Room.php

@ -2,7 +2,7 @@
namespace Moxl\Xec\Action\Ping;
use App\Widgets\Rooms\Rooms as RoomsRooms;
use App\Widgets\Rooms\Rooms as WidgetRooms;
use Movim\ChatroomPings;
use Moxl\Xec\Action;
use Moxl\Stanza\Ping;
@ -29,6 +29,6 @@ class Room extends Action
public function error(string $errorId, ?string $message = null)
{
(new RoomsRooms())->ajaxExit($this->_room);
(new WidgetRooms())->ajaxExit($this->_room);
}
}
Loading…
Cancel
Save