1
0
Fork 0
mirror of synced 2024-06-29 19:50:26 +12:00

fchange realtime method names

This commit is contained in:
Torsten Dittmann 2021-03-01 12:28:13 +01:00
parent 3e92d28cc8
commit e79c5e93d0
5 changed files with 14 additions and 14 deletions

View file

@ -280,7 +280,7 @@ $server->on('open', function (Server $server, Request $request) use (&$connectio
$server->close($connection); $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)); $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) { $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); Console::info('Connection close: ' . $fd);
}); });

View file

@ -113,7 +113,7 @@ class Realtime
* @param array $roles * @param array $roles
* @param array $channels * @param array $channels
*/ */
static function addSubscription($projectId, $connection, $roles, &$subscriptions, &$connections, &$channels) static function subscribe($projectId, $connection, $roles, &$subscriptions, &$connections, &$channels)
{ {
/** /**
* Build Subscriptions Tree * Build Subscriptions Tree
@ -156,7 +156,7 @@ class Realtime
* @param array $subscriptions * @param array $subscriptions
* @param array $connections * @param array $connections
*/ */
static function removeSubscription($connection, &$subscriptions, &$connections) static function unsubscribe($connection, &$subscriptions, &$connections)
{ {
$projectId = $connections[$connection]['projectId'] ?? ''; $projectId = $connections[$connection]['projectId'] ?? '';
$roles = $connections[$connection]['roles'] ?? []; $roles = $connections[$connection]['roles'] ?? [];

View file

@ -60,7 +60,7 @@ class RealtimeChannelsTest extends TestCase
] ]
])); ]));
Realtime::addSubscription( Realtime::subscribe(
'1', '1',
$this->connectionsCount, $this->connectionsCount,
Realtime::getRoles(), Realtime::getRoles(),
@ -82,7 +82,7 @@ class RealtimeChannelsTest extends TestCase
'$id' => '' '$id' => ''
])); ]));
Realtime::addSubscription( Realtime::subscribe(
'1', '1',
$this->connectionsCount, $this->connectionsCount,
Realtime::getRoles(), Realtime::getRoles(),
@ -127,13 +127,13 @@ class RealtimeChannelsTest extends TestCase
*/ */
$this->assertCount($this->connectionsTotal, $this->connections); $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->connectionsTotal, $this->connections);
$this->assertCount(($this->connectionsAuthenticated + (3 * $this->connectionsPerChannel) + 2), $this->subscriptions['1']); $this->assertCount(($this->connectionsAuthenticated + (3 * $this->connectionsPerChannel) + 2), $this->subscriptions['1']);
for ($i = 0; $i < $this->connectionsCount; $i++) { 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); $this->assertCount(($this->connectionsCount - $i - 1), $this->connections);
} }

View file

@ -45,7 +45,7 @@ class RealtimeGuestTest extends TestCase
$this->assertArrayNotHasKey('account', $channels); $this->assertArrayNotHasKey('account', $channels);
$this->assertArrayNotHasKey('account.456', $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 = [ $event = [
@ -201,13 +201,13 @@ class RealtimeGuestTest extends TestCase
$this->assertEmpty($receivers); $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->connections);
$this->assertCount(1, $this->subscriptions['1']); $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->connections);
$this->assertEmpty($this->subscriptions); $this->assertEmpty($this->subscriptions);

View file

@ -69,7 +69,7 @@ class RealtimeTest extends TestCase
$this->assertArrayNotHasKey('account', $channels); $this->assertArrayNotHasKey('account', $channels);
$this->assertArrayNotHasKey('account.456', $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 = [ $event = [
'project' => '1', 'project' => '1',
@ -219,13 +219,13 @@ class RealtimeTest extends TestCase
$this->assertEmpty($receivers); $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->connections);
$this->assertCount(7, $this->subscriptions['1']); $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->connections);
$this->assertEmpty($this->subscriptions); $this->assertEmpty($this->subscriptions);