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] 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 40aaa24..52de0a8 100644 --- a/config/websockets.php +++ b/config/websockets.php @@ -13,6 +13,7 @@ return [ [ '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 4f13d57..d25b223 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 dcb1784..62707c7 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 @@ class App 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 a0ded0f..196a22e 100644 --- a/src/Apps/ConfigAppProvider.php +++ b/src/Apps/ConfigAppProvider.php @@ -67,6 +67,10 @@ class ConfigAppProvider implements AppProvider $app->setName($appAttributes['name']); } + if (isset($appAttributes['server'])) { + $app->setServer($appAttributes['server']); + } + $app ->enableClientMessages($appAttributes['enable_client_messages']) ->enableStatistics($appAttributes['enable_statistics']);