AbydosGater Posted December 8, 2009 Share Posted December 8, 2009 Hi, I have been considering making a PHP/Ajax chat room. Im wondering what is the best way of going about this? I have used many Ajax chat scripts that really are instant, but the only way I can think of going about this is by using polling. Having the Ajax check the server every 5 seconds and have PHP load any new messages. Even at 5 seconds it would put strain on the server if there were many users, but only updating messages every 5 seconds doesnt seem very efficient. Most ajax chat scripts I have used are instant, as if they are event based like normal IM Clients. How can this be achieved with Ajax and PHP? Andyyy Quote Link to comment Share on other sites More sharing options...
Philip Posted December 8, 2009 Share Posted December 8, 2009 Repeatedly poll the server until something happens (pull technology) or have the server tell you when something happens (push technology). Last one is more difficult to implement, but also better on your resources. Search Google for implementation examples. I know a lot of the bigger sites use Comet If you want to just use AJAX, your only real option is to keep polling. Quote Link to comment Share on other sites More sharing options...
JustLikeIcarus Posted December 9, 2009 Share Posted December 9, 2009 Yes King is correct if you want instant response you need a comet based solution. There is a non-comet one known as long-polling you can also look into. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.