Skip to content

Commit 930305a

Browse files
tomschlickroshangautam
authored andcommitted
[feature] toggle broadcasting
* adds the ability to toggle broadcasting on/off * allows setting the specific channel name it should broadcast on.
1 parent e9eeeac commit 930305a

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

config/totem.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,4 +228,9 @@
228228
'whitelist' => true,
229229
],
230230
'database_connection' => env('TOTEM_DATABASE_CONNECTION'),
231+
232+
'broadcasting' => [
233+
'enabled' => env('TOTEM_BROADCASTING_ENABLED', true),
234+
'channel' => env('TOTEM_BROADCASTING_CHANNEL', 'task.events'),
235+
],
231236
];

src/Events/BroadcastingEvent.php

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace Studio\Totem\Events;
44

5-
use Studio\Totem\Task;
65
use Illuminate\Broadcasting\PrivateChannel;
76
use Illuminate\Broadcasting\InteractsWithSockets;
87
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
@@ -12,27 +11,22 @@ class BroadcastingEvent extends TaskEvent implements ShouldBroadcast
1211
use InteractsWithSockets;
1312

1413
/**
15-
* @var Task
16-
*/
17-
public $task;
18-
19-
/**
20-
* constructor.
14+
* Get the channels the event should broadcast on.
2115
*
22-
* @param Task $task
16+
* @return \Illuminate\Broadcasting\Channel|\Illuminate\Broadcasting\Channel[]|PrivateChannel
2317
*/
24-
public function __construct(Task $task)
18+
public function broadcastOn()
2519
{
26-
parent::__construct($task);
20+
return new PrivateChannel(config('totem.broadcasting.channel'));
2721
}
2822

2923
/**
30-
* Get the channels the event should broadcast on.
24+
* Toggles event broadcasting on/off based on config value.
3125
*
32-
* @return \Illuminate\Broadcasting\Channel|\Illuminate\Broadcasting\Channel[]|PrivateChannel
26+
* @return bool
3327
*/
34-
public function broadcastOn()
28+
public function broadcastWhen()
3529
{
36-
return new PrivateChannel('task.events');
30+
return config('totem.broadcasting.enabled');
3731
}
3832
}

0 commit comments

Comments
 (0)