Reputation: 1680
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.
Upvotes: 8
Views: 30194
Reputation: 7
Unfortunately you can't make a real time application with PHP it self you can use a framework like Laravel in PHP and use packages like laravel-websockets and create a realtime application. laravel-websockets is really useful for creating a realtime application. laravel and the laravel websokcets with any front end you can do this
http://beyondco.de/docs/laravel-websockets
You can easy create anything with it just try to understand the fundamental concept of websokcets .
Upvotes: 0
Reputation: 1581
I have already developed an application which is not completely Real-time messaging system, but it works like realtime. Built using without any external new frameworks/API, just used known and familiar skills to develop this using: Ajax jquery, PHP, Mysql, Javascript.
Logic used is:
To refresh new messages and throw them in to div tags .load() from ajax jquery is used, to refresh every 0.5secs Javascript is used to set timeout.
Upvotes: 2
Reputation: 1483
You can also use Node.JS with PHP. Creating a Real-Time Chat App with PHP and Node.js
Upvotes: 2
Reputation: 376
Try use for this CppComet open source comet server. There have api for php and other languages. And viwe this chat example or this
Upvotes: 3
Reputation: 5428
I don't know what your exact question is but Websockets is the answer!
https://github.com/crossbario/autobahn-js
https://github.com/voryx/Thruway
(FYI, when you see WAMP in the context of websockets they're talking about something that's not windows/apache/mysql/php)
Upvotes: 0