Next up we have @marcelpociot

He'll be talking about Laravel Broadcasting on @LaraconOnline

Thread šŸ§µ
Follow along at laracon.beyondco.de

It contains some interactive examples.
Two components involved in Broadcasting. Just the communication between Laravel Backend

Everytime you shoot the shoot button confetti's happen in real-time. ( laracon.beyondco.de )
ShootConfetti event. It implements ShouldBroadcast interface. It has broadcastOn() method. It tells Laravel , if event is dispatched and broadcast, where it should be broadcasted to?

There are different channels.
dispatch() method checks if it. should be broadcasted using shouldBroadcast(). If yes, should it broadcasted now or later using broadcastWhen() method.

By default it returns true. to have control over broadcasting the event implement the broadcastWhen method on the event.
broadcast the event and available broadcast drivers like, log, pusher, ably ( never heard about it ), null and redis.

null can be used in CI environment or testing environment.

Redis driver is a low-level driver.
Main essence of Broadcasting is:
Webhooks using Laravel Broadcasting. Wow!
Define a custom broadcasting driver. Do it inside AppServiceProvider

Create a new class called Webhook which implements Broadcaster interface

Few methods like auth, broadcast ( this is what we want )

return our Webhook class from AppServiceProvider
Change broadcast driver to webhook inside .env file

add new webhook connection inside app/broadcasting.php

Put the URL inside Channel() inside broadcastOn() method
We have managed to work with our Backend. Now let our frontend know about event and the data.

We can use Laravel Echo. We can use pusher/ably broadcaster we can just specify that.
Especially useful for real-time communications.

Ajax Polling to fetch messages after few time.

Websocket on the other hand is permanently opened connection which makes it fast. and also help with real-time.
This is beautiful

#laracon
Listening on the public stream and listen for #laracon hashtag and generate HeardTweet and then send it to front-end via Laravel Echo.
Another example. Exporting orders.
User click, he has to wait 10 second.
Second approach, trigger export, it gets queued up, processed in background, you get email that its done.

Another way is to do it in real time.
Exporting
Channels

Two types

Public Channel: exposed to everyone

Private Channel: works same as Public one in the backend.

Echo.private for Private channels instead of Echo.listen
Enable BroadcastServiceProvider because its disabled by default.

Authentication errors on Private channels.

routes/channels.php file and define how we want to authenticate users for different channels

Any authenticated user can join this private channel.
Presence channel works in similar way to Private channel.

Presence channel know about authenticated users who are on the given channel.

Events like .joining() and .leaving() , example of Google Docs
Backend implementation on Laravel. It's pretty simple.
Frontend implementation:

User increment on joining and decrementing on leaving event.

We get auth token from the Backend. For presence channel we also get user information for joining and leaving events.
We can also have b/w one frontend and the other.

Client event in Laravel Echo called, Whispering.

listenForWhisper method from the other frontend clients.
laravel-websockets v2 is coming soon which will bring horizontal scaling.
End of @marcelpociot talk.

ā€¢ ā€¢ ā€¢

Missing some Tweet in this thread? You can try to force a refresh
怀

Keep Current with Zubair Mohsin

Zubair Mohsin Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @Zubairmohsin33

17 Mar
Next up we have @enunomaduro on @LaraconOnline

He'll be telling us about Artisan Console Component

Thread šŸ§µ
Few projects of Nuno running on Artisan console component.
Read 19 tweets
17 Mar
Next up we have @calebporzio talking about @LaravelLivewire and @Alpine_JS

Thread šŸ§µ
of Livewire. Woah!
Show the small things, instead of big things.

Shoutout to @TransistorFM and @noplanstomerge
Read 26 tweets
17 Mar
Next up we have @m1guelpf on @LaraconOnline

He'll be talking about Laraveil Illuminate Foundation

Thread šŸ§µ
laravel/framework requires micro packages namespaced under Illuminate.
Read 17 tweets
17 Mar
Next up, we have @taylorotwell on @LaraconOnline

Thread about keynotes from Taylor's talk.

šŸ§µ
Thanking everyone šŸ˜…
Stupid internet got disconnected. Alright, we are back on.
Read 38 tweets
17 Mar
Next up we have @bobbybouwmann who will be talking about Laravel Router.

Thread šŸ§µ
And now he's updating Zoom in the background šŸ˜‚
That's a good menu
Read 33 tweets
17 Mar
Next up is @christophrumpel talking about Service Container.

Thread šŸ§µ
Cool animation on slides.
Dinner break šŸ˜” can't live-tweet ... Just listening šŸ˜…
Read 21 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!