From 75c9dc7ccd798752d4a65e50ba41544dabf0ea75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C4=8Cekan?= Date: Fri, 24 May 2024 15:00:18 +0200 Subject: [PATCH] Update Pusher.php The uri is badly composed, when url path is defined in config. Base uri for Guzzle is concatenated with config path and therefore, it does not work. Also, in custom websocket server, I need to override the socket id validation to the custom rule, so please set it as protected. --- src/Pusher.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Pusher.php b/src/Pusher.php index 72b6b8a..427dcc8 100755 --- a/src/Pusher.php +++ b/src/Pusher.php @@ -80,7 +80,7 @@ public function __construct(string $auth_key, string $secret, string $app_id, ar $this->settings['auth_key'] = $auth_key; $this->settings['secret'] = $secret; $this->settings['app_id'] = $app_id; - $this->settings['base_path'] = '/apps/' . $this->settings['app_id']; + $this->settings['base_path'] = (isset($options['path']) ? $options['path'] : '') . '/apps/' . $this->settings['app_id']; foreach ($options as $key => $value) { // only set if valid setting/option @@ -217,7 +217,7 @@ private function validate_channel(string $channel): void * * @throws PusherException If $socket_id is invalid */ - private function validate_socket_id(string $socket_id): void + protected function validate_socket_id(string $socket_id): void { if ($socket_id !== null && !preg_match('/\A\d+\.\d+\z/', $socket_id)) { throw new PusherException('Invalid socket ID ' . $socket_id); @@ -265,7 +265,7 @@ private function sign(string $path, string $request_method = 'GET', array $query */ private function channels_url_prefix(): string { - return $this->settings['scheme'] . '://' . $this->settings['host'] . ':' . $this->settings['port'] . $this->settings['path']; + return $this->settings['scheme'] . '://' . $this->settings['host'] . ':' . $this->settings['port']; } /**