I use websockets for chat and online presense, and it is VERY fast. Lets say a person sends a chat message. It gets sent to laravel as a post request which puts it in the queue. The job on the queue, then sends it to my websocket server (I use soketi but you can use pusher.com if you dont want to run your own), which sends it to the client browser. This is very very fast and the message ends up at the recipient in less than a second. And if it is send to multiple users, it is still just as fast.
Websockets best practices
Hello,
I did already few projects with laravel in the future. But just simple with blade-Views and jquery javascript-library for the frontend functionality.
But now I plan something new and would like to use websockets. I already understood the concepts with the server application like nodejs and the javascript client. But my problem is to understand how is the best practice, that the server-part gets the informations fast enough to spread the informations soon to all connected clients.
Just as example: Website wants to show ta current number of registered users and the current likes of a picture, without user has to reload all the page. For that I would want to use websockets.
So any user clicks the like button on the website, I could send this click event to websocket-server and he could update the counter in database spread fast the new number of likes to other clients, that's easy.
But if a user registers, how does the websocket-server notice fast enough the new registrations? Do I have to connect the RegisterController::storeUser() Function as a client to the websocket server to send events? Or has the websocket-server to listen on the database with "Select count() from users;" to get the new numbers?
I really would like to know, how is the best practise for that kind of jobs ...
Best regards Andi
Please or to participate in this conversation.