diff --git a/app/realtime.php b/app/realtime.php index e5308a6a6..2875359a0 100644 --- a/app/realtime.php +++ b/app/realtime.php @@ -280,7 +280,7 @@ $server->on('open', function (Server $server, Request $request) use (&$connectio $server->close($connection); } - Realtime::addSubscription($project->getId(), $connection, $subscriptions, $connections, $roles, $channels); + Realtime::subscribe($project->getId(), $connection, $subscriptions, $connections, $roles, $channels); $server->push($connection, json_encode($channels)); }); @@ -294,7 +294,7 @@ $server->on('message', function (Server $server, Frame $frame) { }); $server->on('close', function (Server $server, int $fd) use (&$connections, &$subscriptions) { - Realtime::removeSubscription($fd, $subscriptions, $connections); + Realtime::unsubscribe($fd, $subscriptions, $connections); Console::info('Connection close: ' . $fd); }); diff --git a/src/Appwrite/Realtime/Realtime.php b/src/Appwrite/Realtime/Realtime.php index 03cc7ffb6..62e2be5d5 100644 --- a/src/Appwrite/Realtime/Realtime.php +++ b/src/Appwrite/Realtime/Realtime.php @@ -113,7 +113,7 @@ class Realtime * @param array $roles * @param array $channels */ - static function addSubscription($projectId, $connection, $roles, &$subscriptions, &$connections, &$channels) + static function subscribe($projectId, $connection, $roles, &$subscriptions, &$connections, &$channels) { /** * Build Subscriptions Tree @@ -156,7 +156,7 @@ class Realtime * @param array $subscriptions * @param array $connections */ - static function removeSubscription($connection, &$subscriptions, &$connections) + static function unsubscribe($connection, &$subscriptions, &$connections) { $projectId = $connections[$connection]['projectId'] ?? ''; $roles = $connections[$connection]['roles'] ?? []; diff --git a/tests/unit/Realtime/RealtimeChannelsTest.php b/tests/unit/Realtime/RealtimeChannelsTest.php index daa657b04..afe52373b 100644 --- a/tests/unit/Realtime/RealtimeChannelsTest.php +++ b/tests/unit/Realtime/RealtimeChannelsTest.php @@ -60,7 +60,7 @@ class RealtimeChannelsTest extends TestCase ] ])); - Realtime::addSubscription( + Realtime::subscribe( '1', $this->connectionsCount, Realtime::getRoles(), @@ -82,7 +82,7 @@ class RealtimeChannelsTest extends TestCase '$id' => '' ])); - Realtime::addSubscription( + Realtime::subscribe( '1', $this->connectionsCount, Realtime::getRoles(), @@ -127,13 +127,13 @@ class RealtimeChannelsTest extends TestCase */ $this->assertCount($this->connectionsTotal, $this->connections); - Realtime::removeSubscription(-1, $this->subscriptions, $this->connections); + Realtime::unsubscribe(-1, $this->subscriptions, $this->connections); $this->assertCount($this->connectionsTotal, $this->connections); $this->assertCount(($this->connectionsAuthenticated + (3 * $this->connectionsPerChannel) + 2), $this->subscriptions['1']); for ($i = 0; $i < $this->connectionsCount; $i++) { - Realtime::removeSubscription($i, $this->subscriptions, $this->connections); + Realtime::unsubscribe($i, $this->subscriptions, $this->connections); $this->assertCount(($this->connectionsCount - $i - 1), $this->connections); } diff --git a/tests/unit/Realtime/RealtimeGuestTest.php b/tests/unit/Realtime/RealtimeGuestTest.php index aba7e6845..d8d19c2d0 100644 --- a/tests/unit/Realtime/RealtimeGuestTest.php +++ b/tests/unit/Realtime/RealtimeGuestTest.php @@ -45,7 +45,7 @@ class RealtimeGuestTest extends TestCase $this->assertArrayNotHasKey('account', $channels); $this->assertArrayNotHasKey('account.456', $channels); - Realtime::addSubscription('1', 1, $roles, $this->subscriptions, $this->connections, $channels); + Realtime::subscribe('1', 1, $roles, $this->subscriptions, $this->connections, $channels); $event = [ @@ -201,13 +201,13 @@ class RealtimeGuestTest extends TestCase $this->assertEmpty($receivers); - Realtime::removeSubscription(2, $this->subscriptions, $this->connections); + Realtime::unsubscribe(2, $this->subscriptions, $this->connections); $this->assertCount(1, $this->connections); $this->assertCount(1, $this->subscriptions['1']); - Realtime::removeSubscription(1, $this->subscriptions, $this->connections); + Realtime::unsubscribe(1, $this->subscriptions, $this->connections); $this->assertEmpty($this->connections); $this->assertEmpty($this->subscriptions); diff --git a/tests/unit/Realtime/RealtimeTest.php b/tests/unit/Realtime/RealtimeTest.php index 3ff373b9d..29af833ee 100644 --- a/tests/unit/Realtime/RealtimeTest.php +++ b/tests/unit/Realtime/RealtimeTest.php @@ -69,7 +69,7 @@ class RealtimeTest extends TestCase $this->assertArrayNotHasKey('account', $channels); $this->assertArrayNotHasKey('account.456', $channels); - Realtime::addSubscription('1', 1, $roles, $this->subscriptions, $this->connections, $channels); + Realtime::subscribe('1', 1, $roles, $this->subscriptions, $this->connections, $channels); $event = [ 'project' => '1', @@ -219,13 +219,13 @@ class RealtimeTest extends TestCase $this->assertEmpty($receivers); - Realtime::removeSubscription(2, $this->subscriptions, $this->connections); + Realtime::unsubscribe(2, $this->subscriptions, $this->connections); $this->assertCount(1, $this->connections); $this->assertCount(7, $this->subscriptions['1']); - Realtime::removeSubscription(1, $this->subscriptions, $this->connections); + Realtime::unsubscribe(1, $this->subscriptions, $this->connections); $this->assertEmpty($this->connections); $this->assertEmpty($this->subscriptions);