Creating a real-time chat with php and javascript

Thanasis1101 picture Thanasis1101 · Jun 14, 2017 · Viewed 23.9k times · Source

My goal is to create a real-time chat similar to the Facebook chat, from scratch. I want to store all the messages on a database table (MySQL) and every time a new message is sent by a user, if the receiver is connected then a request will be sent to the receiver's browser and the message will appear on the chat window.

I don't want to have the client to check if a new message for the user was sent, but I want the server to send the request to the client's browser.

I know that this can be achieved using the Comet technique (I saw this stackoverflow question) but I am not able to find a good guide on how to implement this for this certain problem.

I want to use php and javascript and as less extra software or frameworks as possible.

I use WAMPServer and I have Windows.

If you know a good guide or tutorial or can provide any guidelines on how I could achieve what I want, it would be very helpful.

Answer

Trapenok Victor picture Trapenok Victor · Jul 13, 2017

Try use for this CppComet open source comet server. There have api for php and other languages. And viwe this chat example or this