3 ms·
I'm surprised to read that the Campfire servers does a mysql connect on each poll. I built an internal tool for my company similar to Campfire but allowed tabb
by dugmartin 17y ago
I'm surprised to read that the Campfire servers does a mysql connect on each poll. I built an internal tool for my company similar to Campfire but allowed tabbed conversations in the same window (so that you can have a visible thread running with a few people without bothering others).
To store messages I used a simple PHP script that wrote out a json object per line to a file named with room+date. To poll for messages when you opened the client it would query the poller script with the room name and it would return all the json objects for the current day as an array plus the length of the file. On each subsequent poll the client would send the room name + the file offset - the server script would then open the file, jump to the offset and read in the rest of the file and return it as an array (empty if no new content) plus the new length of the file. It scaled really well (not that we had Campfire sized loads).