-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[1.x] Allow to listen for MessageReceived event #134
Conversation
Update Server.php [1.x] Allow non-Pusher and ClientEvent messages
Thanks for the pull request, but right now the plan is to support solely the Pusher protocol. There is scope within Reverb to provide support for additional protocols, so I could see a future where we ship a plain WebSocket server, but right now, the focus is on Pusher only. |
Hope you reconsider. Seems like a wasted opportunity to add great general purpose tool in the Laravel toolkit. It doesn't seem to add any maintenance overhead and worked perfectly with this single change. A good trade-off to allow to receive messages and process them in the same Laravel app from various devices and clients. |
I would also like to point out that this change just allows the data, that is already received and parsed by the websocket server and available, to be used (listened to) by everybody. |
Pusher
and ClientEvent
messages
Laravel Socialite for example allows to implement your own providers along the Laravel provided ones. It should be the case for Reverb too. |
"I have never written a single private class or method in an OS repo in my entire career Like free speech, open source code is only truly open if someone you don't like can use and extend your code in ways that you disagree with, and you can't do anything about it" - Steve Bauman Let developer listen to the message received event for all types of messages. There can be a new MessageHandled event for those that are handled by Reverb. |
@rihardsgrislis feel free to fork this project and modify this entirely in the way you want 👍 |
@driesvints I rest my case now. This websocket server is too awesome. Together with FrankenPHP running one is such a delightful developer experience and I never want to go through something else. So, yeah, I'm forking it already. websocket:
image: ghcr.io/rihardsgrislis/my-app/app:main
container_name: reverb_websocket
working_dir: /app
command: [ "php", "artisan", "reverb:start" ] # , "--debug"
restart: unless-stopped
ports:
- "8080:8080" |
Hey,
Love using Reverb so far! 🚀
I would like to use the websocket server to receive non-Laravel messages from other clients as well and handle the messages in my app. I have some IoT devices that allow for outbound websocket.
The
MessageReceived
event is already implemented and I can just listen for it in the app. However it doesn't get executed because if the message doesn't contain the "event" key the server fails handling the message (Undefined array key "event"
) and sends'event' => 'pusher:error'
event to the client with message "Invalid message format".We just need to check for the "event" key before using the
Pusher
orClientEvent
handler.