From 30d1a6b79cf164b958fcb5c9aa3fc406fbec4bb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20K=C3=A4mmerling?= Date: Wed, 5 Dec 2018 12:36:02 +0100 Subject: [PATCH 1/3] Add server variable --- config/websockets.php | 1 + resources/views/dashboard.blade.php | 2 +- src/Apps/App.php | 10 ++++++++++ src/Apps/ConfigAppProvider.php | 4 ++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/config/websockets.php b/config/websockets.php index 40aaa24eeb..52de0a87fb 100644 --- a/config/websockets.php +++ b/config/websockets.php @@ -13,6 +13,7 @@ [ 'id' => env('PUSHER_APP_ID'), 'name' => env('APP_NAME'), + 'server' => null, 'key' => env('PUSHER_APP_KEY'), 'secret' => env('PUSHER_APP_SECRET'), 'enable_client_messages' => false, diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard.blade.php index 4f13d57930..d25b223126 100644 --- a/resources/views/dashboard.blade.php +++ b/resources/views/dashboard.blade.php @@ -109,7 +109,7 @@ methods: { connect() { this.pusher = new Pusher(this.app.key, { - wsHost: window.location.hostname, + wsHost: this.app.server.length === 0 ? window.location.hostname : this.app.server, wsPort: this.port, disableStats: true, authEndpoint: '/{{ request()->path() }}/auth', diff --git a/src/Apps/App.php b/src/Apps/App.php index dcb17843f4..62707c7855 100644 --- a/src/Apps/App.php +++ b/src/Apps/App.php @@ -18,6 +18,9 @@ class App /** @var string|null */ public $name; + /** @var string|null */ + public $server; + /** @var bool */ public $clientMessagesEnabled = false; @@ -63,6 +66,13 @@ public function setName(string $appName) return $this; } + public function setServer(string $server) + { + $this->server = $server; + + return $this; + } + public function enableClientMessages(bool $enabled = true) { $this->clientMessagesEnabled = $enabled; diff --git a/src/Apps/ConfigAppProvider.php b/src/Apps/ConfigAppProvider.php index a0ded0f665..196a22eada 100644 --- a/src/Apps/ConfigAppProvider.php +++ b/src/Apps/ConfigAppProvider.php @@ -67,6 +67,10 @@ protected function instanciate(?array $appAttributes): ?App $app->setName($appAttributes['name']); } + if (isset($appAttributes['server'])) { + $app->setServer($appAttributes['server']); + } + $app ->enableClientMessages($appAttributes['enable_client_messages']) ->enableStatistics($appAttributes['enable_statistics']); From 3f48a0fe503b6f6a3fbb006b0d9e7f068e731e82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20K=C3=A4mmerling?= Date: Wed, 5 Dec 2018 13:58:30 +0100 Subject: [PATCH 2/3] Rename `server` to `host` --- config/websockets.php | 1 - resources/views/dashboard.blade.php | 2 +- src/Apps/App.php | 6 +++--- src/Apps/ConfigAppProvider.php | 4 ++-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/config/websockets.php b/config/websockets.php index 52de0a87fb..40aaa24eeb 100644 --- a/config/websockets.php +++ b/config/websockets.php @@ -13,7 +13,6 @@ [ 'id' => env('PUSHER_APP_ID'), 'name' => env('APP_NAME'), - 'server' => null, 'key' => env('PUSHER_APP_KEY'), 'secret' => env('PUSHER_APP_SECRET'), 'enable_client_messages' => false, diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard.blade.php index d25b223126..6f951f93b9 100644 --- a/resources/views/dashboard.blade.php +++ b/resources/views/dashboard.blade.php @@ -109,7 +109,7 @@ methods: { connect() { this.pusher = new Pusher(this.app.key, { - wsHost: this.app.server.length === 0 ? window.location.hostname : this.app.server, + wsHost: this.app.host.length === 0 ? window.location.hostname : this.app.host, wsPort: this.port, disableStats: true, authEndpoint: '/{{ request()->path() }}/auth', diff --git a/src/Apps/App.php b/src/Apps/App.php index 62707c7855..b11023db0c 100644 --- a/src/Apps/App.php +++ b/src/Apps/App.php @@ -19,7 +19,7 @@ class App public $name; /** @var string|null */ - public $server; + public $host; /** @var bool */ public $clientMessagesEnabled = false; @@ -66,9 +66,9 @@ public function setName(string $appName) return $this; } - public function setServer(string $server) + public function setHost(string $host) { - $this->server = $server; + $this->host = $host; return $this; } diff --git a/src/Apps/ConfigAppProvider.php b/src/Apps/ConfigAppProvider.php index 196a22eada..786c9e2026 100644 --- a/src/Apps/ConfigAppProvider.php +++ b/src/Apps/ConfigAppProvider.php @@ -67,8 +67,8 @@ protected function instanciate(?array $appAttributes): ?App $app->setName($appAttributes['name']); } - if (isset($appAttributes['server'])) { - $app->setServer($appAttributes['server']); + if (isset($appAttributes['host'])) { + $app->setHost($appAttributes['host']); } $app From 5245ba8098a6b5927a781743bedf1445897aad45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20K=C3=A4mmerling?= Date: Wed, 5 Dec 2018 14:38:42 +0100 Subject: [PATCH 3/3] Do not test the length of the host value, check if it is null --- resources/views/dashboard.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard.blade.php index 6f951f93b9..679f37fd7f 100644 --- a/resources/views/dashboard.blade.php +++ b/resources/views/dashboard.blade.php @@ -109,7 +109,7 @@ methods: { connect() { this.pusher = new Pusher(this.app.key, { - wsHost: this.app.host.length === 0 ? window.location.hostname : this.app.host, + wsHost: this.app.host === null ? window.location.hostname : this.app.host, wsPort: this.port, disableStats: true, authEndpoint: '/{{ request()->path() }}/auth',