N
N
Nikolay Semenov2017-07-29 09:56:31
JavaScript
Nikolay Semenov, 2017-07-29 09:56:31

How to make private chat between two users in php, yii?

Hello everyone)
Making a website in yii? you need to implement a private chat between users there (for example, as in vk, facebook). We did it on sockets, but there is only a common chat room, we don’t know how to close it. Maybe someone has code examples or tutorials.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Viktor, 2017-07-29
@Levhav

If you decide to use CppComet instead of screwing the sockets yourself, then out of the box there is a mechanism for private messages and user authorization on the comet server.
Example of sending private messages

I
Igor Vasiliev, 2017-08-08
@Isolution666

Hello Nikolay.
In this situation, you really need sockets, I implemented something similar in Yii2 via Ajax, using two parameters, id - the user and his token, the token is individual for each user, so you can use it to create many different paired dialogs, and then find dialogs using this token , and display on the page. In the case of unique IDs and tokens, there is no risk that millions of other dialogs will be confused, and with the help of a token, you can sort the correspondence so that the last message is at the bottom, and through javascript scroll the window down all the time so that the user sees what they wrote to him, without manually scrolling .
My method may be a crutch, for someone, but I myself came up with it this way, it still works and does not fail. Try it, good luck.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question