wip
This commit is contained in:
parent
23cf67045d
commit
c1cd4a520e
|
|
@ -24,7 +24,7 @@ class PresenceChannel extends Channel
|
||||||
$this->saveConnection($connection);
|
$this->saveConnection($connection);
|
||||||
|
|
||||||
$channelData = json_decode($payload->channel_data);
|
$channelData = json_decode($payload->channel_data);
|
||||||
$this->users[$connection->socketId] = $channelData;
|
$this->users[$channelData->user_id] = $channelData;
|
||||||
|
|
||||||
// Send the success event
|
// Send the success event
|
||||||
$connection->send(json_encode([
|
$connection->send(json_encode([
|
||||||
|
|
@ -57,10 +57,15 @@ class PresenceChannel extends Channel
|
||||||
|
|
||||||
protected function getChannelData(): array
|
protected function getChannelData(): array
|
||||||
{
|
{
|
||||||
|
$hash = [];
|
||||||
|
foreach ($this->users as $socketId => $channelData) {
|
||||||
|
$hash[$channelData->user_id] = $channelData->user_info;
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'presence' => [
|
'presence' => [
|
||||||
'ids' => array_values(array_map(function($channelData) { return $channelData->user_id; }, $this->users)),
|
'ids' => array_values(array_map(function($channelData) { return (string)$channelData->user_id; }, $this->users)),
|
||||||
'hash' => array_map(function($channelData) { return $channelData->user_info; }, $this->users),
|
'hash' => $hash,
|
||||||
'count' => count($this->users)
|
'count' => count($this->users)
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue