A
A
AlexSer2019-10-16 09:24:40
Yii
AlexSer, 2019-10-16 09:24:40

How to make instant notification to all users in Yii2?

Prompt the algorithm. How can I make an instant notification to all users.
Let's say there are categories of goods with a certain quantity. And if the product runs out of stock, it is necessary that the administrator "turn off" the product. and users who were on the site received an informational message that the product is closed or unavailable.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
BATPYIIIKOB, 2019-10-16
@AlexSer

Or use web sockets, there are examples of chats.
Or, on the frontend, set the JS interval to poll through AJAX for changes in the availability of goods, and display a notification.

M
Moses Fender, 2019-10-16
@mosesfender

To have a certain buffer with messages that have a limited lifetime, I would generally do this with files. The admin makes some movement that creates the file. The browsers of all users poll some action that gives them these messages, with a frequency of, say, 10 seconds. The user sees the message, closes it, writes the message ID to the cookie with a lifetime of 1 hour so that it does not fall out anymore. An hour later, the file on the server is also deleted.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question