SMF Development > Applied or Declined Requests
Forum Spy
Daniel15:
This looks quite interesting, I'll see if I can code up something similar (as usual, no promises!).
Basically, it checks an XML feed every 15 seconds, for any new posts. If there's some new posts, they're added to the table (one entry each second, so people don't get overwhelmed with posts flooding in :P). As SMF already has an XML feed inbuilt, this would be almost entirely client-side.
Rudolf:
Daniel, if you do write something like this, make sure to add a setting for the update frequency. Since this is ajax, you can even add a way to shape the frequency based on the server load, dynamically. The higher the load the slower the update time.
Without this feature this would make the servers to crawl even on the small-medium forums - if the users start to use it.
Hints: What happens when the number of returned topics is greater then 15 sec. The script is still loading up the topics in the table and a new request will be made. This would cause some parallel insertions, a total mess. Therefore, you need to write your script to don't send an update request only when the "cache" is empty.
Two, I haven't looked at the other script to see how it handles the topic queue, but topics that go over the bottom of the table should be removed from the page. Think DOM. ;)
That's it for now.
Daniel15:
--- Quote ---Hints: What happens when the number of returned topics is greater then 15 sec. The script is still loading up the topics in the table and a new request will be made. This would cause some parallel insertions, a total mess.
--- End quote ---
I think it uses a queue - When a new request is made, all the new posts are pushed to the end of the queue.
I haven't looked through that code properly yet, but I may use it as inspiration (I never copy-and-paste code from someone else, I just use their code as inspiration for my own :)). I saw that they're using a JavaScript library (Prototype.js, I think... I'd personally use Scriptaculous or mootools :))
Harro:
Also take a look at jQuery.
http://jquery.com
http://visualjquery.com
That's a javascript library i've been using lately.
Kinda like it :)
Daniel15:
OK, to see what I've done so far, take a look at http://rpl.dev.dansoftaustralia.net/smf/index.php?action=recentlive. It initially loads the latest 5 posts into the list, and then checks every 10 seconds for new ones. Open that page in a new browser window/tab, and then make a new topic (you may login with the username and password of "test"). After a few seconds, you'll see your new post appear in the list :).
You can get the code from its SVN repository (http://dev.dansoftaustralia.net/scm/?group_id=23), but there's no guarantees it will work for you (and I'm not giving any support yet). If you have any suggestions, please tell me :D
--- Quote ---That's a javascript library i've been using lately.
Kinda like it
--- End quote ---
Looks nice, I may consider using it.
The only libraries I'm familiar with at the moment are Scriptaculous (which uses Prototype.js) and mootools. I love mootools because it's so lightweight (5 - 40 KB packed, depending on the options you choose when downloading it).
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version