A
A
Andrew Detmer2018-04-03 07:51:04
Yii
Andrew Detmer, 2018-04-03 07:51:04

Implementation of notifications. Loops in Yii2?

Hey!
There is a yii2-basic application. There is a notification model, a controller and a database for them, everything is ready. Notifications work like an alarm clock. The database records the time when the notification should fire. So, I can’t understand, but in what place and in what way to implement a time check?
When I wrote for the desktop, there was always some kind of main loop where the whole thing could be twisted. And here I can’t understand which way to look and where to insert such a cycle. Or are cycles not needed at all?
I thought in the direction of the background cycle, demons (although I don’t quite understand what it is and how), in the direction of AJAX (but it’s still not clear where the cycle is?), in the direction of , which would be updated every few seconds, in the direction of the client-side cycle through js, but that seems like an ugly solution.<frame>
Tell me at least where to dig, you can even link to some examples. I will be glad to any infe!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey Gavrilov, 2018-04-03
@Andrew_Detmer

Write a console application (controller) that accesses the database and sends (processes as you need) notifications. Hang up its execution on cron (let's say once a minute). profit.

S
Sergey Vorobyov, 2018-04-03
@alert2006

If the load is small, you can pull Ajax through setInterval ( https://javascript.ru/setinterval)

M
Maxim Fedorov, 2018-04-03
@qonand

If correctly I understand notifications at you should be deduced at clients in the browser. In this case, you should dig towards using sockets.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question