T
T
temakorolev12020-10-18 00:45:46
PHP
temakorolev1, 2020-10-18 00:45:46

How to implement sending and receiving notifications in real time on the site?

Front of the site is written in ReactJS, Back - php + sql. A notification system has been developed, i.e. all notification information is stored in the database, but so far it only works after the page is reloaded. I was advised to use websockets. And I need advice. Maybe there are frameworks, libraries, ready-made examples for solving this problem for these tools that I listed above?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey Maslov, 2020-10-22
@lelick

Try centrifugo:
https://github.com/centrifugal/centrifugo
For php they have a library:
https://github.com/centrifugal/phpcent

X
xenonhammer, 2020-10-18
@xenonhammer

Ajax shouldn't be a problem. Did you work with promises?
Send a request to the server, display information depending on the response. And it will all work without reloading the page.
If everything is tied to transitions there, then I have a question, do you use react-routes? I think not, but it should, and then everything will work fine too

M
McBernar, 2020-10-19
@McBernar

Maybe you don't need reel time. Then it is enough to send a simple request in the background every n seconds. If you need it instantly, then socket.io will help you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question