In my current setup, I am utilizing Laravel 5.6.7, Socket.IO, and vue.js while excluding Pusher and Redis. The following is the code snippet I am using to send messages directly to a user engaged in one-on-one chatting with me.
var url = "http://localhost:6001/apps/My_appId/events?auth_key=My_Key";
var socketId = Echo.socketId();
var request = {
"channel": "private-Send-Message-Channel.2",
"name": "MessengerEvent",
"data": {
"msg": message
},
"socket_id": socketId
};
axios.post(url, JSON.stringify(request)).then((response) => {
//Message Sent
});
I am exploring ways to notify the user I'm chatting with that I am currently typing a message. Is it necessary to use the same code above, which triggers an XMLHttpRequest for each keystroke? Is this the only method available to convey to the user that typing is ongoing?
Update 1
Is there a more efficient approach instead of posting an XMLHttpRequest for every key press as mentioned earlier? In case the user types 200 characters, does that mean I'll have to trigger an XMLHttpRequest 200 times?
Alternatively,
Does Laravel offer events like whisper and listenForWhisper, similar to what's detailed here https://laravel.com/docs/5.6/broadcasting#client-events? My tech stack involves vue.js and laravel 5.6.7, and I'm not utilizing Pusher nor Redis.