E
E
Evgeny Khripunov2018-07-27 00:22:46
Redis
Evgeny Khripunov, 2018-07-27 00:22:46

Is it possible to store unread private Laravel echo events in redis and deliver them if the user is logged into the channel?

There is a system of personal correspondence on websocket (Laravel echo + redis).
When authorizing on the site, the user subscribes to the laravel-echo private channel with id equal to the user id.
Messages (events) to other channels are stored in the database and delivered regardless of whether the person is currently in that channel or not. (You can find out about the presence of a person in a channel only if you are a member of one channel, but we have each user his own channel with an id equal to the user id).
How to implement a system of read/unread events? Each time to send a request to the database that the message was read irrationally.
Is it possible to somehow store Laravel-echo events in redis, deliver unread events to the user when he authorizes on the site and clear them after the user authorizes?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Aksentiev, 2018-07-27
@Sanasol

Make notifications via https://laravel.com/docs/5.6/notifications
They can be displayed as you like unread counters or a list, even all that.
And at the same time send them to the websocket https://laravel.com/docs/5.6/notifications#broadca
... persistent alerts + realtime output is obtained.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question