How Can I listen or subscribe to pusher:pong event using Vue pusher echo? - laravel

I'm using the Vue + Laravel pusher in my Realtime app.
I realized that client sends "pusher:ping" event to backend and it responds with "pusher:pong" based on Doc.
I was wondering how can I detect if the socket connection is alive?
Is there a way to subscribe or listen to the protocol level events?
Thanks

Related

can not show messages received in console with pusher and websocket

for project i used pusher to create realtime chat using laravel 9 . i can send message from front end to backend with api but can not received messages from backend
chat channel created but won't show up anything
for example when an event called backend completely received that but could not send anything or can not connect to channel
js :
Echo.channel('chat').listen('.MyMessage', (e) => {
console.log(e)
})
could anyone help me ?

how do i send data from webhook to frontend?

I have an API that continuously sends data to a webhook in my express server. The route in my server looks something like this:
app.post("/webhook", (req, res) => {
console.log(req.body);
res.status(200).end();
});
How do I send data to my frontend as they're coming in? Is it possible to place a websocket between my frontend and backend? If so, can anyone please point to a tutorial? Much appreciated, thanks.
I would recommend to use socket.io to enable a bidirectional comunication between your frontend and backend.
Each time the third party API sends data throught your webhook, you could trigger a socket event and receive a realtime update in your front end.
check: https://socket.io
It's simple and have a good documentation.

How to subscribe websocket by Chrome extensions?

I am try to implement a basic web socket app by following this tutorial:https://spring.io/guides/gs/messaging-stomp-websocket/
However, in that tutorial there was a client UI implementation. I don't want to use UI. Instead of the UI, I want to use a websocket client extension in Chrome for sending and seeing messages.
All codes same with the tutorial(except the UI part since I'dont want UI), so I don't rewrite all codes here.
I am able to connect and send message to the url: ws://localhost:8081/gs-guide-websocket for example,
However, I can't get response with this url: ws://localhost:8081/topic/greetings. (I use this URL for getting responses by subscribing it. Because this topic/greetings path used in the UI side of that tutorial for subscription)
The Chrome extension that I used is Simple WebSocket Client.
Why I couldn't subscribe the ws://localhost:8081/topic/greetings url? and How can I get messages from the server by using the Chrome client websocket extensions?
Your application works with STOMP and SockJs, this plugin does not support that. It only works with ws. In this example, you can write a simple ws endpoint for your application:
example simple ws endpoint

Laravel listen socket.io client emit

I have chat application using Laravel + laravel-echo-server + Redis.
currently i am using http api request from client to send message.
But its slow if i have large client number.
Is there a way to send message from client to server through socket and listen in laravel?
Probably something like this
public function onMessage($client, $data)
{
.....
}
i already tried laravel-websocket, but if i set APP_DEBUG=false in .env CustomSocketHandler unable to work anymore.
Thank you.

Implement Ajax calls via XMPP messages

I have a website where users are connected with XMPP server (ejabberd). I want to replace my ajax calls with xmpp messages to reduce the load on apache server.
ie
a replace for ajax call, which works on following ideas
Send a XMPP message
Add a handler which is fired when the data for the specific ajax request is answered through a message
Is there a wrapper to do the same?
You could take a look at strophe.js.
It's a pretty powerful JavaScript library for doing XMPP in the browser.

Resources