Renamed the prop to replicator
This commit is contained in:
parent
4389fd1360
commit
0ebf223584
|
|
@ -13,13 +13,13 @@ use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
class FetchChannelsController extends Controller
|
class FetchChannelsController extends Controller
|
||||||
{
|
{
|
||||||
/** @var ReplicationInterface */
|
/** @var ReplicationInterface */
|
||||||
protected $pubsub;
|
protected $replicator;
|
||||||
|
|
||||||
public function __construct(ChannelManager $channelManager, ReplicationInterface $pubsub)
|
public function __construct(ChannelManager $channelManager, ReplicationInterface $replicator)
|
||||||
{
|
{
|
||||||
parent::__construct($channelManager);
|
parent::__construct($channelManager);
|
||||||
|
|
||||||
$this->pubsub = $pubsub;
|
$this->replicator = $replicator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __invoke(Request $request)
|
public function __invoke(Request $request)
|
||||||
|
|
@ -51,7 +51,7 @@ class FetchChannelsController extends Controller
|
||||||
|
|
||||||
// We ask the replication backend to get us the member count per channel.
|
// We ask the replication backend to get us the member count per channel.
|
||||||
// We get $counts back as a key-value array of channel names and their member count.
|
// We get $counts back as a key-value array of channel names and their member count.
|
||||||
return $this->pubsub
|
return $this->replicator
|
||||||
->channelMemberCounts($request->appId, $channelNames)
|
->channelMemberCounts($request->appId, $channelNames)
|
||||||
->then(function (array $counts) use ($channels, $attributes) {
|
->then(function (array $counts) use ($channels, $attributes) {
|
||||||
return [
|
return [
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ class Channel
|
||||||
protected $channelName;
|
protected $channelName;
|
||||||
|
|
||||||
/** @var ReplicationInterface */
|
/** @var ReplicationInterface */
|
||||||
protected $pubsub;
|
protected $replicator;
|
||||||
|
|
||||||
/** @var \Ratchet\ConnectionInterface[] */
|
/** @var \Ratchet\ConnectionInterface[] */
|
||||||
protected $subscribedConnections = [];
|
protected $subscribedConnections = [];
|
||||||
|
|
@ -23,7 +23,7 @@ class Channel
|
||||||
public function __construct(string $channelName)
|
public function __construct(string $channelName)
|
||||||
{
|
{
|
||||||
$this->channelName = $channelName;
|
$this->channelName = $channelName;
|
||||||
$this->pubsub = app(ReplicationInterface::class);
|
$this->replicator = app(ReplicationInterface::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getChannelName(): string
|
public function getChannelName(): string
|
||||||
|
|
@ -68,7 +68,7 @@ class Channel
|
||||||
$this->saveConnection($connection);
|
$this->saveConnection($connection);
|
||||||
|
|
||||||
// Subscribe to broadcasted messages from the pub/sub backend
|
// Subscribe to broadcasted messages from the pub/sub backend
|
||||||
$this->pubsub->subscribe($connection->app->id, $this->channelName);
|
$this->replicator->subscribe($connection->app->id, $this->channelName);
|
||||||
|
|
||||||
$connection->send(json_encode([
|
$connection->send(json_encode([
|
||||||
'event' => 'pusher_internal:subscription_succeeded',
|
'event' => 'pusher_internal:subscription_succeeded',
|
||||||
|
|
@ -81,7 +81,7 @@ class Channel
|
||||||
unset($this->subscribedConnections[$connection->socketId]);
|
unset($this->subscribedConnections[$connection->socketId]);
|
||||||
|
|
||||||
// Unsubscribe from the pub/sub backend
|
// Unsubscribe from the pub/sub backend
|
||||||
$this->pubsub->unsubscribe($connection->app->id, $this->channelName);
|
$this->replicator->unsubscribe($connection->app->id, $this->channelName);
|
||||||
|
|
||||||
if (! $this->hasConnections()) {
|
if (! $this->hasConnections()) {
|
||||||
DashboardLogger::vacated($connection, $this->channelName);
|
DashboardLogger::vacated($connection, $this->channelName);
|
||||||
|
|
@ -120,7 +120,7 @@ class Channel
|
||||||
// in this case. If this came from TriggerEventController, then we still want
|
// in this case. If this came from TriggerEventController, then we still want
|
||||||
// to publish to get the message out to other server instances.
|
// to publish to get the message out to other server instances.
|
||||||
if ($publish) {
|
if ($publish) {
|
||||||
$this->pubsub->publish($appId, $this->channelName, $payload);
|
$this->replicator->publish($appId, $this->channelName, $payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Performance optimization, if we don't have a socket ID,
|
// Performance optimization, if we don't have a socket ID,
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ class PresenceChannel extends Channel
|
||||||
public function getUsers(string $appId)
|
public function getUsers(string $appId)
|
||||||
{
|
{
|
||||||
// Get the members list from the replication backend
|
// Get the members list from the replication backend
|
||||||
return $this->pubsub
|
return $this->replicator
|
||||||
->channelMembers($appId, $this->channelName);
|
->channelMembers($appId, $this->channelName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -49,7 +49,7 @@ class PresenceChannel extends Channel
|
||||||
$this->users[$connection->socketId] = $channelData;
|
$this->users[$connection->socketId] = $channelData;
|
||||||
|
|
||||||
// Add the connection as a member of the channel
|
// Add the connection as a member of the channel
|
||||||
$this->pubsub
|
$this->replicator
|
||||||
->joinChannel(
|
->joinChannel(
|
||||||
$connection->app->id,
|
$connection->app->id,
|
||||||
$this->channelName,
|
$this->channelName,
|
||||||
|
|
@ -59,7 +59,7 @@ class PresenceChannel extends Channel
|
||||||
|
|
||||||
// We need to pull the channel data from the replication backend,
|
// We need to pull the channel data from the replication backend,
|
||||||
// otherwise we won't be sending the full details of the channel
|
// otherwise we won't be sending the full details of the channel
|
||||||
$this->pubsub
|
$this->replicator
|
||||||
->channelMembers($connection->app->id, $this->channelName)
|
->channelMembers($connection->app->id, $this->channelName)
|
||||||
->then(function ($users) use ($connection) {
|
->then(function ($users) use ($connection) {
|
||||||
// Send the success event
|
// Send the success event
|
||||||
|
|
@ -86,7 +86,7 @@ class PresenceChannel extends Channel
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the connection as a member of the channel
|
// Remove the connection as a member of the channel
|
||||||
$this->pubsub
|
$this->replicator
|
||||||
->leaveChannel(
|
->leaveChannel(
|
||||||
$connection->app->id,
|
$connection->app->id,
|
||||||
$this->channelName,
|
$this->channelName,
|
||||||
|
|
@ -110,7 +110,7 @@ class PresenceChannel extends Channel
|
||||||
*/
|
*/
|
||||||
public function toArray(string $appId = null)
|
public function toArray(string $appId = null)
|
||||||
{
|
{
|
||||||
return $this->pubsub
|
return $this->replicator
|
||||||
->channelMembers($appId, $this->channelName)
|
->channelMembers($appId, $this->channelName)
|
||||||
->then(function ($users) {
|
->then(function ($users) {
|
||||||
return array_merge(parent::toArray(), [
|
return array_merge(parent::toArray(), [
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue