Monday, April 04, 2011 at 1:06 AM.
rssCloudSuite.receivePing
on receivePing (url, flLog) { <<Changes <<10/24/09; 10:02:38 AM by DW <<Having a global minsecs proved too brutal for Lifeline feeds, which could easily change more often than every three minutes. So I set the default of the global minsecs to 0 and added a feed-level minsecs. <<10/21/09; 10:59:58 PM by DW <<Make sure ctsecs > 0. <<"The server, rpc.rsscloud.org, returned error code 4: Can't accept the request because the minimum seconds between pings is 180 and you pinged us -955956556 seconds ago." <<10/20/09; 1:29:05 PM by DW <<Don't delete the changes table entry right after you inserted it (changes.xml was broken since October 2). <<10/2/09; 10:33:05 AM by DW <<Tweak the log message a bit. <<9/4/09; 9:25:34 PM by DW <<Eliminate other instances of the feed in the changes table. <<7/12/09; 5:50:56 PM by DW <<Call this when a feed you're maintaining has changed. local (adrdata = rssCloudSuite.init (), adrfeed = rssCloudSuite.initFeed (url), now = clock.now (), startticks = clock.ticks ()); rssCloudSuite.checkEnabled (); //scripterror if not enabled bundle { //10/21/09 by DW -- reject too-often pingers local (minsecs = adrdata^.prefs.minSecsBetweenPings); if adrfeed^.prefs.minSecsBetweenPings > minsecs { //10/24/09 by DW minsecs = adrfeed^.prefs.minSecsBetweenPings}; if minsecs > 0 { local (ctsecs = number (now - adrfeed^.whenLastCheck)); if ctsecs > 0 { if ctsecs < minsecs { scriptError ("Can't accept the request because the minimum seconds between pings is " + minsecs + " and you pinged us " + ctsecs + " seconds ago.")}}}}; adrfeed^.ctChecks++; adrfeed^.whenLastCheck = now; local (tc = clock.ticks ()); adrfeed^.ctTicksLastRead = clock.ticks () - tc; local (s = tcp.httpreadurl (url, ctFollowRedirects:5)); local (hash = string.hashMD5 (s)); if adrfeed^.lastHash != hash { adrfeed^.fldirty = true} else { if adrfeed^.lastSize != sizeof (s) { adrfeed^.fldirty = true}}; adrfeed^.lastHash = hash; adrfeed^.lastSize = sizeof (s); if adrfeed^.fldirty { thread.callscript (@rssCloudSuite.notifySubscribers, {nameof (adrfeed^)}); adrfeed^.ctUpdates++; adrfeed^.whenLastUpdate = now}; bundle { //log the ping if flLog { local (feedinfo, feedlink); rssCloudSuite.getFeedInfo (url, @feedinfo); bundle { //set feedlink if defined (feedinfo.title) { feedlink = "The feed, <a href=\"" + url + "\">" + feedinfo.title + "</a>, "} else { feedlink = "This <a href=\"" + url + "\">feed</a>"}}; local (s = feedlink + " was said to have changed. We checked and the claim appears to be " + adrfeed^.fldirty + "."); log2.add (rssCloudInfo.name, "Ping", s, startticks)}}; bundle { //push it on the changes table, 9/4/09 by DW local (adrdata = rsscloudsuite.init ()); local (adrchange = @adrdata^.changes.[string.padwithzeros (++adrdata^.stats.ctChanges, 8)]); new (tabletype, adrchange); adrchange^.name = string (adrdata^.stats.ctChanges); adrchange^.when = now; adrchange^.url = url; bundle { //remove other instances of the feed in the changes table local (i, adr); for i = sizeof (adrdata^.changes) downto 1 { adr = @adrdata^.changes [i]; if adr^.url == url { if adr != adrchange { //10/20/09 by DW delete (adr)}}}}; adrdata^.stats.flChangesDirty = true}; adrfeed^.fldirty = false; return (true)}; bundle { //test code receivePing ("http://scripting.com/rss.xml", true)}
This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.