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