Event Broadcasting Flashcards
What are the current broadcasting drivers supported by Laravel?
Pusher, Redis and a log driver
What is the purpose of the log driver?
The log driver is for local development and debugging.
Additionally what other driver is available to disable broadcasting?
The “null” driver.
Before being able to broadcast any events what service provider needs to be registered in config/app.php file?
BroadcastServiceProvider
What is the name of the token required by Laravel Echo for auth?
CSRF Token
By default where does Laravel Echo look for the Laravel.csrfToken javascript object?
resources/views/layouts/app.blade.php
At the start of a project what command will generate the app.blade.php file?
make:auth Artisan command
If you are not using the default layout where would you define the meta tag for CRSF token?
In your applications head HTML element.
If your using Pusher to broadcast events what is the prerequisite package required?
pusher/pusher-php-server
Where would you config your Pusher credentials?
In the config/broadcasting.php configuration file.
What are the additional options provided in the config/broadcastsing.php file?
cluster and encrypted
When using Pusher and Laravel Echo where you specify Pusher as your desired broadcaster within resources/assets/js/ ?
bootstrap.js
When you are using Redis as broadcaster what composer command would you use to fetch the required library?
composer require predis/predis
In order for Redis to work what does it need to be paired with?
A WebSocket server
By default where would you include the Socket.IO Javascript client library?
In your applications head HTML element.
What is the name of currently maintained Socket.IO server GitHub repository?
tlaverdure/laravel-echo-server
Before broadcasting events what will you need to configure and run, helping the response time of your application?
Queue Listener
What are the two basic types of channels events can be broadcast over?
public and private
What is the difference between public and private channels?
In order for a user to subscribe to a private channel a user must be authenticated and authorized to listen.
In order for to broadcast an event what interface is required?
ShouldBroadcast:
class ShippingStatusUpdated implements ShouldBroadcast
What is the purpose of the broadcastOn() method?
This method is responsible for returning the channels that the event should broadcast on.
Where would we define our channel authorization rules?
routes/channels.php
What are the two arguments accepted by the channel method?
the name of the channel and a callback which returns true or false indicating whether the user is authorized to listen on the channel.
What do all the authorization callbacks on the channel method receive as the first method?
The currently authenticated user