-4

I wanted to learn, how to make "notification"/"chat" like thing of facebook and google. I searched through all web/ almost stack overflow questions to get my answer, but all I end up not making even a single chat box. I searched and have a great confusion between : 1. "Pinging Server each second" and "Long Polling" are two terms different for same technique or techniques are also different??? Explanation and demo please. 2. APE (AJAX Push Engine) Explanation and Demo please. 3. Socket.IO and Node.js Explanation and Demo please. 4. Ratchet (php) , I tried this hard, but ended up nowhere. Explanation and Demo please.

Which one is the best method ? For push notification or say real time web apps? and is easy to implement on WAMP windows server

You can expect me to be 1 level up from beginner. In Push Notification, Database needs to be checked for new updates, but for private two-party chat no database is required, its what I think. But its legal to save chat logs, & So above both for my requirements needs to handle php file also in the real time. Please Help.

1 Answers1

1

I don't have a total answer for you, but I did build a PHP based chat/group client w/PM functionality. It was a fun project but failed under stress (100+ people on group chat - I suspect client server was not ready).

It has been a few years since then, but there were many problems to solve in building it from scratch.

I used a 1-5 second update script in javascript to check the server for updates.

Updates were (more or less) a path like : site.com/app/{username}/{hash}/

I used user+hash to serialize content to the user and make the app harder to hack (hash was user ID+salt via SHA1). The endpoint would return json with unix time. If the unix time was greater than unix time the new responses were put to the the chat window (ajax+append). The actual operation was more complicated than that broad stroke, but the key point is made.

There were so many nuisances to the application and weird problems I did not see when planning. I studied existing protocols to get pointers, but in the end I learned 2 things :

1-not worth building as I found some open source projects out there.

and 2 - PHP was not as real happy, I think the DB socket caught on fire under load.

And you now have my $0.02

Marc
  • 1,895
  • 18
  • 25