php - Laravel socket live chat without a broadcast event

one text

I use Laravel websockets and Echo to create a simpel live chat. But there is something I don't understand.

I have 2 servers:

  1. Laravel application with Laravel Echo (the chat frontend)
  2. Laravel server with Laravel websocket installed.

When a user sends a message, a post request will go to server 1. Server 1 will dispatch a sent message event to the socket server (server 2):

event(new NewMessage($channel, $message));

Meanwhile the chat is listening to the socket server:

    Echo.channel(channel).listen('NewMessage', (data) => {
        console.log(data.question)
    })

This all works fine, and according to documentation I read this is the way to go. The problem I have, is that I feel the post request to send a message is completly unnecesary. I don't store the message in a database or anything. So the only thing the post request does is sending the message to a server, which then sends the message to the next server. So that's a unnecesary post request for every message sent.

In the docs they mention something about Laravel echo Whisper, which they use to send a "someone is typing" kind of update:

.whisper('typing', {
    name: "me"
});

and to listen to messages:

.listenForWhisper('typing', (e) => {
    console.log(e.name);
});

Would it be smart to use this to send messages? Or are there an other way to bypass the post request?

Source