E
E
ErickSkrauch2014-02-07 19:12:52
PHP
ErickSkrauch, 2014-02-07 19:12:52

How to implement private chat on the site?

I have a thematic project with elements of a social network. The most important thing, as you understand, is a chat between people. I looked towards dklab_realplexor for a long time, but now I doubt that it will suit me.
So how I want to do:

  1. When entering the site, the user connects to the server, preferably via sockets, and downloads all unread messages.
  2. When a new message arrives, the user receives this message on the connection, and the message is also entered into the database (MySQL, although you can also try MongoDB).
  3. As soon as the user has downloaded the message, he sends the "Accepted" status to the same socket, so that the state would not turn out when the user disconnected, but the server did not know about it yet.

This is the blueprint for how I see it at work. In fact, I don’t even quite understand how to implement it :)
Let me explain why I refused the realplexor. Firstly, I have no idea how to catch the first message event - either connect to all friends at once, or create a general channel, which will entail the ability to read the first message of each dialogue. Secondly, creating a channel for each dialogue and following it is not an option, it seems to me, although it is possible that he knows how to clean empty channels himself, I could be wrong.
Of the possible implementations, I consider either php modules or a node implementation, but I wrote too little on the node, so I won’t write it myself through the well-known socket.io (at least I still can’t imagine how to send packets to a specific destination, and even more so to several (in the case of several windows)), so a ready-made and finished solution is desirable on the node.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Konstantin T, 2014-02-08
@RooTooZ

Node.js and angular.js can help you.
An example can be peeped on GitHub

V
Viktor, 2014-10-20
@Levhav

You can try this comet service , everything that you described there can be implemented without problems.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question