Skip to content

Commit

Permalink
rework broadcast message
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Dec 21, 2016
1 parent feac7dd commit 40f30f1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 22 deletions.
3 changes: 2 additions & 1 deletion src/Illuminate/Notifications/Channels/BroadcastChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ public function send($notifiable, Notification $notification)
);

if ($message instanceof BroadcastMessage) {
$event->connection = 'sync';
$event->onConnection($message->connection)
->onQueue($message->queue);
}

return $this->events->fire($event);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

namespace Illuminate\Notifications\Events;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

class BroadcastNotificationCreated implements ShouldBroadcast
{
use SerializesModels;
use Queueable, SerializesModels;

/**
* The notifiable entity who received the notification.
Expand Down
23 changes: 4 additions & 19 deletions src/Illuminate/Notifications/Messages/BroadcastMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,19 @@

namespace Illuminate\Notifications\Messages;

use Illuminate\Bus\Queueable;

class BroadcastMessage
{
use Queueable;

/**
* The data for the notification.
*
* @var array
*/
public $data;

/**
* Determine if the message should be broadcasted immediately.
*
* @var array
*/
public $broadcastNow = false;

/**
* Create a new message instance.
*
Expand All @@ -41,16 +38,4 @@ public function data($data)

return $this;
}

/**
* Broadcast this message immediately.
*
* @return $this
*/
public function now()
{
$this->broadcastNow = true;

return $this;
}
}
2 changes: 1 addition & 1 deletion tests/Notifications/NotificationBroadcastChannelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@ public function toArray($notifiable)

public function toBroadcast()
{
return (new \Illuminate\Notifications\Messages\BroadcastMessage([]))->now();
return (new \Illuminate\Notifications\Messages\BroadcastMessage([]))->onConnection('sync');
}
}

0 comments on commit 40f30f1

Please sign in to comment.