Pjax, Ajax, Yii 2, how to update the content on the side of the interlocutor?

The bottom line is, there is a base data, where the stored correspondence many different dialogues, each dialogue for two people. When writing a message with his hand Pjax works and I without a reboot see what is written to the interlocutor, but the interlocutor correspondence is not updated. What complicates the very correspondence, update the page by hand is unacceptable!

How to do so, updated correspondence from all who wrote using Pjax, or just write a javascript code that will update the content on the side of the interlocutor if the database has a new entry, and this update did not touch those who have not posted.

There id who wrote, id who has written, token is a unique correspondence(dialogue).
Tell me, where is the solution. I will be very grateful to know how it looks and works.
July 2nd 19 at 14:17
2 answers
July 2nd 19 at 14:19
Of course you can implement everything using Ajax to send a request which monitors new message, etc., but this method of spike and fit only for very small projects. In General writing chat php as I don't really fit, but if You for some reason have chosen, it is better to realize it's all socket-based
I don't have chats, and dialogues, correspondence between users, Ajax is used only for adding records to DB, I don't know how big is my project, but want to err on the load of 500 000 people a day. - oliver_Grant99 commented on July 2nd 19 at 14:22
July 2nd 19 at 14:21
supports Your problem in the wrong choice of tool. To make chat need via sockets. With the usual ajax will be difficult.
However, in html5 there is a worker-s, here is the article, I think what You should do:
https://habrahabr.ru/post/132785/
I don't really understand what sockets, and they are better than ajax or javascript technologies, an article to read, thank you for the information. - oliver_Grant99 commented on July 2nd 19 at 14:24
: sockets, if rough, will allow You to keep a constant connection to the server and receive data as soon as the change occurred (said source). With ajax it is necessary to constantly throw the request to the server checking did not answer it. - oliver_Grant99 commented on July 2nd 19 at 14:27

Find more questions by tags YiiAJAX