Ciprian Mocanu
Ciprian Mocanu

Reputation: 2196

Laravel receive messages from Pusher

I successfully implemented Pusher and Laravel 5.5 by looking at examples online, however, eveywhere I look, in order for Laravel to receive anything from the user, the user does POST. But, if the user is connected through a socket, why can't the user send messages through the socket and Laravel listen?

I realize that this would imply that there should be some sort of Laravel server (that would always be connected to the socket), but I don't know exactly if Laravel doesn't already have this, or maybe if there is a library out there.

In other words, I want the client to send to Pusher via websocket and Laravel to listen (just like any other client) and then send back message.

EDIT: Or, what other socket solution for Laravel could I use? I first wanted to use Meteor, but I've already built all my admin in Laravel, so I don't want to move now..

Upvotes: 1

Views: 1381

Answers (1)

Vytautas Krutulis
Vytautas Krutulis

Reputation: 109

I believe Pusher Webhooks is what you are looking for. You'll have to setup an Endpoint i.e. yourapp.com/webhooks/pusher and everytime client sends an event through the socket your backend application will receive a notification at the URL given, so for example you can save the clients message in your database.

You can find more info here: https://pusher.com/docs/webhooks

Upvotes: 1

Related Questions