Log in

View Full Version : suggestions on creating instant messaging



pman
02-08-2008, 02:21 AM
Hi,

I wasn't sure exactly in which forum I should post, but let me know. As the title suggests, I want to create a chat client that is web based.

I know I can use ajax to post messages to the database and then using ajax display new messages. The way displaying will work is if I send a request every 1 or 2 seconds to check the database for new message and then display it.

But that's really not instant messaging, if you know what I mean. Is there any alternatives so that after someone posts something it will appear on message display without needing to wait for the server to receive a request and then display it?

jackbenimble4
02-08-2008, 03:41 AM
Nope. Not while using PHP and Javascript exclusively at least. You can however increase the refresh time enough that the lag is minimal. I wrote a chat application like this for my community using ajax, php and xml. It worked pretty well even with a 2.4 second refresh lapse.

Anyways, I don't believe what you're looking for is possible with PHP. Most instant messaging clients work by downloading the ip address and port of the clients you communicate with to your machine. That way your messages are relayed to the other person directly with no server in between. As far as I know, this is not possible without installing software on the user's machine.

djr33
02-08-2008, 04:19 AM
This is possible using a java applet as done with irc chats. However, it's not possible with just javascript/php as js is limited to person-machine and php is limited machine-machine (aside from the actual request and output which are person-machine).

pman
02-09-2008, 03:17 PM
Thanks everyone for your reply. I was also thinking the same, but thought I would ask to make sure.