FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


PHP-based Chatroom





noobcake
Does anyone have any idea of how to create a PHP-based chatroom server? I'd like to dynamically make some channels, and not just one huge chat room for everyone. Also, it would be great to make it scalable. I was thinking of storing messages in a database and using ajax to retrieve messages, but it sounds kinda slow. Any better ideas?
jmraker
I've made a chat in php and used ajax. If you don't design it right it could accidently create a denial of service where too many update requests come in. (I used an ajax chat app that I found and the server load shot up and the whole site was slow).

When I designed the chat I added.
. The server tells the browser when to update again, it uses sys_getloadavg() and slows the requests down if the server is slow
. The server can tell the browser to refresh the page if there's an important javascript update, otherwise the bad javascript will keep running.
. You can add javascript event listeners to figure out if they're looking at the page. If they aren't looking at the page it can update less.
. Only send new info on every update, there's no need to send the last hours worth of chat every 5 seconds.

. I think the ideal solution is looking into socket connections where the server pushes the chat, so on every new message the server sends the message to every open chat connection. As far as I know it requires web server support, plus flash or browser support for sockets
tokodemo
well good job, where's your page?
Related topics
Anyone want to try out my PHP-based support ticket software?
Need a php-based FAQ system
Buying PHP based RPG
PHP & Chat
PHP - BBcode Parsing
PHP Login Problem
Checking server status (ports) using PHP
Rate it - New PHP site...
php script to set up ftp users on linux
Making a PHP filemanager *finished*
Python v Perl v php for Wiki advice needed
Using php to change content of a .txt
php CMS require some 777 permissions?
Securely connect 2 PHP servers
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.