Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
gilour
/
foundation
/
src
/
Websockets
/
API
:
WebsocketProviderAPI.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php namespace Common\Websockets\API; use Illuminate\Http\Client\PendingRequest; use Illuminate\Support\Collection; use Illuminate\Support\Facades\Http; abstract class WebsocketProviderAPI { protected array $cache = []; public function __construct(protected array $options = []) { } abstract public function getAllChannels(): Collection; abstract public function getActiveUsersInChannel( string $channel, ): Collection; protected function getClient(): PendingRequest { return Http::throwIf($this->options['throw'] ?? false); } protected function makeRequestWithCaching(string $path, array $params = []) { $cacheKey = $path . json_encode($params); if (isset($this->cache[$cacheKey])) { return $this->cache[$cacheKey]; } $response = $this->getClient() ->get($path, $params) ->json(); $this->cache[$cacheKey] = $response; return $response; } }