rename channel id to channel name
This commit is contained in:
parent
acaa7aa205
commit
8648a182b3
|
|
@ -18,7 +18,7 @@ class Channel
|
|||
|
||||
public function __construct(string $channelName)
|
||||
{
|
||||
$this->channelId = $channelName;
|
||||
$this->channelName = $channelName;
|
||||
}
|
||||
|
||||
public function hasConnections(): bool
|
||||
|
|
@ -33,7 +33,7 @@ class Channel
|
|||
|
||||
protected function verifySignature(ConnectionInterface $connection, stdClass $payload)
|
||||
{
|
||||
$signature = "{$connection->socketId}:{$this->channelId}";
|
||||
$signature = "{$connection->socketId}:{$this->channelName}";
|
||||
|
||||
if (isset($payload->channel_data)) {
|
||||
$signature .= ":{$payload->channel_data}";
|
||||
|
|
@ -53,7 +53,7 @@ class Channel
|
|||
|
||||
$connection->send(json_encode([
|
||||
'event' => 'pusher_internal:subscription_succeeded',
|
||||
'channel' => $this->channelId
|
||||
'channel' => $this->channelName
|
||||
]));
|
||||
}
|
||||
|
||||
|
|
@ -62,7 +62,7 @@ class Channel
|
|||
unset($this->subscriptions[$connection->socketId]);
|
||||
|
||||
if (! $this->hasConnections()) {
|
||||
DashboardLogger::vacated($connection, $this->channelId);
|
||||
DashboardLogger::vacated($connection, $this->channelName);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -73,10 +73,10 @@ class Channel
|
|||
$this->subscriptions[$connection->socketId] = $connection;
|
||||
|
||||
if (! $hadConnectionsPreviously) {
|
||||
DashboardLogger::occupied($connection, $this->channelId);
|
||||
DashboardLogger::occupied($connection, $this->channelName);
|
||||
}
|
||||
|
||||
DashboardLogger::subscribed($connection, $this->channelId);
|
||||
DashboardLogger::subscribed($connection, $this->channelName);
|
||||
}
|
||||
|
||||
public function broadcast($payload)
|
||||
|
|
|
|||
|
|
@ -12,17 +12,17 @@ class ChannelManager
|
|||
/** @var array */
|
||||
protected $channels = [];
|
||||
|
||||
public function findOrCreate(string $appId, string $channelName): Channel
|
||||
{
|
||||
if (!isset($this->channels[$appId][$channelName])) {
|
||||
$channelClass = $this->determineChannelClass($channelName);
|
||||
public function findOrCreate(string $appId, string $channelName): Channel
|
||||
{
|
||||
if (!isset($this->channels[$appId][$channelName])) {
|
||||
$channelClass = $this->determineChannelClass($channelName);
|
||||
|
||||
$this->channels[$appId][$channelName] = new $channelClass($channelName);
|
||||
}
|
||||
|
||||
return $this->channels[$appId][$channelName];
|
||||
$this->channels[$appId][$channelName] = new $channelClass($channelName);
|
||||
}
|
||||
|
||||
return $this->channels[$appId][$channelName];
|
||||
}
|
||||
|
||||
public function find(string $appId, string $channelName): ?Channel
|
||||
{
|
||||
return $this->channels[$appId][$channelName] ?? null;
|
||||
|
|
|
|||
|
|
@ -29,13 +29,13 @@ class PresenceChannel extends Channel
|
|||
// Send the success event
|
||||
$connection->send(json_encode([
|
||||
'event' => 'pusher_internal:subscription_succeeded',
|
||||
'channel' => $this->channelId,
|
||||
'channel' => $this->channelName,
|
||||
'data' => json_encode($this->getChannelData())
|
||||
]));
|
||||
|
||||
$this->broadcastToOthers($connection, [
|
||||
'event' => 'pusher_internal:member_added',
|
||||
'channel' => $this->channelId,
|
||||
'channel' => $this->channelName,
|
||||
'data' => json_encode($channelData)
|
||||
]);
|
||||
}
|
||||
|
|
@ -46,7 +46,7 @@ class PresenceChannel extends Channel
|
|||
|
||||
$this->broadcastToOthers($connection, [
|
||||
'event' => 'pusher_internal:member_removed',
|
||||
'channel' => $this->channelId,
|
||||
'channel' => $this->channelName,
|
||||
'data' => json_encode([
|
||||
'user_id' => $this->users[$connection->socketId]->user_id
|
||||
])
|
||||
|
|
|
|||
Loading…
Reference in New Issue