Skip to content

Commit

Permalink
Compatiblity with mercure 0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
mvanduijker committed Nov 16, 2019
1 parent 34d4cdb commit 47db50a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
],

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/BroadcasterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down

0 comments on commit 47db50a

Please sign in to comment.