From 47db50a0cc2c068cad0676a9e8ce25bd9512cc09 Mon Sep 17 00:00:00 2001 From: Mark van Duijker Date: Sat, 16 Nov 2019 13:16:31 +0100 Subject: [PATCH] Compatiblity with mercure 0.8 --- README.md | 8 ++++---- composer.json | 2 +- tests/Feature/BroadcasterTest.php | 2 +- tests/TestCase.php | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index f99f798..914c2cc 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ return [ 'mercure' => [ 'driver' => 'mercure', - 'url' => env('MERCURE_URL', 'http://localhost:3000/hub'), + 'url' => env('MERCURE_URL', 'http://localhost:3000/.well-known/mercure'), 'secret' => env('MERCURE_SECRET', 'aVerySecretKey'), ], @@ -70,7 +70,7 @@ class NewsItemCreated implements ShouldBroadcast In your frontend do something like: ```javascript -var es = new EventSource('http://localhost:3000/hub?topic=' + encodeURIComponent('http://example/news-items')); +var es = new EventSource('http://localhost:3000/.well-known/mercure?topic=' + encodeURIComponent('http://example/news-items')); es.addEventListener('message', (messageEvent) => { var eventData = JSON.parse(messageEvent.data); console.log(eventData); @@ -129,7 +129,7 @@ class MercureBroadcasterAuthorizationCookie 'mercureAuthorization', (string) $token, 15, - '/hub', // or which path you have mercure running + '/.well-known/mercure', // or which path you have mercure running parse_url(config('app.url'), PHP_URL_HOST), $secure, true @@ -173,7 +173,7 @@ class DirectMessageCreated implements ShouldBroadcast Example Frontend: ```javascript -var es = new EventSource('http://localhost:3000/hub?topic=' + encodeURIComponent('http://example/user/1/direct-messages'), { withCredentials: true }); +var es = new EventSource('http://localhost:3000/.well-known/mercure?topic=' + encodeURIComponent('http://example/user/1/direct-messages'), { withCredentials: true }); es.addEventListener('message', (messageEvent) => { var eventData = JSON.parse(messageEvent.data); console.log(eventData); diff --git a/composer.json b/composer.json index 1426db2..3f86b5e 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "php": "^7.1", "illuminate/broadcasting": "~5.6.0|~5.7.0|~5.8.0|~6.0", "lcobucci/jwt": "~3.2", - "symfony/mercure": "~0.1" + "symfony/mercure": "~0.3" }, "require-dev": { "larapack/dd": "^1.0", diff --git a/tests/Feature/BroadcasterTest.php b/tests/Feature/BroadcasterTest.php index e284b28..09c7290 100644 --- a/tests/Feature/BroadcasterTest.php +++ b/tests/Feature/BroadcasterTest.php @@ -43,7 +43,7 @@ private function assertMercureDockerLog(callable $matcher) /** @before */ public function startMercureServer() { - $command = "docker run -d -e JWT_KEY='aVerySecretKey' -e DEMO=1 -e ALLOW_ANONYMOUS=1 -e PUBLISH_ALLOWED_ORIGINS='http://localhost' -p 3000:80 dunglas/mercure:v0.7"; + $command = "docker run -d -e JWT_KEY='aVerySecretKey' -e DEMO=1 -e ALLOW_ANONYMOUS=1 -e PUBLISH_ALLOWED_ORIGINS='http://localhost' -p 3000:80 dunglas/mercure"; $this->mercureDockerContainerId = Process::fromShellCommandline($command) ->mustRun() diff --git a/tests/TestCase.php b/tests/TestCase.php index 0cdbb41..7023244 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -10,7 +10,7 @@ protected function getEnvironmentSetUp($app) { $app['config']->set('broadcasting.default', 'mercure'); $app['config']->set('broadcasting.connections.mercure.driver', 'mercure'); - $app['config']->set('broadcasting.connections.mercure.url', 'http://localhost:3000/hub'); + $app['config']->set('broadcasting.connections.mercure.url', 'http://localhost:3000/.well-known/mercure'); $app['config']->set('broadcasting.connections.mercure.secret', 'aVerySecretKey'); }