Description
It is finally time to connect to our socket server and start serving broadcasting events to our users. In this tutorial part, we will be creating our event, which we will trigger server-side when we hit the new comment API point that we created in the last video.
As soon as we submit a new comment to that API endpoint, we will trigger the event after it saves, and pass the new comment's details to the socket server.
On the server side we can just use the basic Laravel event/listener system, except that we won't bother ourselves with listeners. Listeners can still be used to run scripts server-side when an event is triggered, but our primary concern is to trigger events and then broadcast those events, which will be sent to our socket server on Pusher.com.
On the client-side we will use Laravel Echo to subscribe to channels when the page loads. This will prepare our clients to accept any new events that come down the tube while we are subscribed. Then we will tell Laravel Echo what to do when we hear the NewComment event, and use Vue.js to update the newest comment into our comments array, so that it is automatically displayed in the comments feed.
In the end we will have a powerful live commenting realtime engine. It will be a great example of what can be done with websockets and Laravel echo!
Next Up: We learn about how to use Private Channels to only allow authenticated users access to the channels.
==== WRITTEN TUTORIALS ====
"Mastering Websockets in Laravel" Master Series Page:
https://devmarketer.io/learn/laravel-echo-tutorial-websockets/
Part 3: Handling Socket Server Events
Coming Soon
==== MORE FROM THIS SERIES . ====
Full Playlist for the "Mastering Websockets in Laravel" Series:
https://www.youtube.com/playlist?list=PLwAKR305CRO9rlj-U9oOi4m2sQaWN6XA8
==== DOWNLOAD SOURCE CODE ====
Github Code Repo for this Series:
https://github.com/DevMarketer/Laravel_Echo_Tutorial
Download Code for Part3
https://github.com/DevMarketer/Laravel_Echo_Tutorial/releases/tag/Part3
==== FOLLOW ME ====
Subscribe for New Releases!
Subscribe to DevMarketer Insider (Email)
https://confirmsubscription.com/h/d/5EDC91CF554832D1
Twitter - http://twitter.com/_jacurtis
(ask me questions!)
==== QUESTIONS? ====
Leave a comment below and I or someone else can help you.
For quick questions you may also want to ask me on Twitter, I respond almost immediately.
Email me hello@jacurtis.com
Thanks for all your support!