Monday, April 04, 2011 at 1:06 AM.
rssCloudSuite.notifyOne
on notifyOne (adrsubscription, flLog=true) { <<Changes <<3/16/11; 12:00:38 AM by DW <<Don't try to log the subscription if it's undefined. <<10/2/09; 10:39:28 AM by DW <<Improve log message. <<9/13/09; 9:59:47 AM by DW <<If HTTP returned code from POST is 400 or greater, return an error. <<7/21/09; 12:17:55 PM by DW <<Setting the timeout has no effect when its not possible to open a connection on the server because tcp.openStream doesn't take a timeout parameter. It's always 20 seconds, near as I can tell. Once I get into the C source again I'll have to check this out. <<7/19/09; 11:20:01 AM by DW <<Optional param, flLog, defaults true. If we're just testing the connection we don't want to log the notification. <<7/19/09; 8:53:56 AM by DW <<Created. Factored out of notifySubscribers. local (adrdata = rssCloudSuite.init (), startticks = clock.ticks (), flerror = false); local (server = nameof (adrsubscription^), feedurl = nameof (parentof (adrsubscription^)^)); rssCloudSuite.initSubscription (adrsubscription); local (adrsubscriber = @adrdata^.subscribers.[server]); system.temp.rssCloud.ctNotifyThreads++; try { if server beginswith "http://" { //special case for http-post local (params, code); new (tabletype, @params); params.url = feedurl; tcp.httppost (server, @params, adrcode:code); if number (code) >= 400 { //9/13/09 by DW scripterror ("HTTP error code " + code + ".")}} else { if server beginswith "xmlrpc://" { //we need to set the timeout so we have to go low-level local (urllist = string.urlSplit (server), domain = urllist [2], port = 80, params = {feedurl}); if domain contains ":" { port = string.nthField (domain, ':', string.countFields (domain, ':')); domain = string.popSuffix (domain, ':')}; betty.rpc.client (domain, port, adrsubscriber^.notifyProcedure, @params, rpcPath:urllist [3], fldebug:false, flShowMessages:false, ticksToTimeOut:adrdata^.prefs.notifyTimeoutTicks)} else { [server].[adrsubscriber^.notifyProcedure] (feedurl)}}; adrsubscription^.whenLastUpdate = clock.now (); adrsubscription^.ctUpdates++; adrsubscription^.ctConsecutiveErrors = 0} <<bundle //log the event <<local (urllist = string.urlsplit (server)) <<local (servername = string.nthfield (urllist [2], ":", 1)) //pop the port off the name of the server <<local (protocolname = urllist [1] - "://") <<local (s = "Subscriber <a href=\"" + server + "\">" + servername + "</a> was notified that the <a href=\"" + feedurl + "\"> feed</a> has changed via <i>" + protocolname + "</i> protocol.") <<log2.add (rssCloudInfo.name, "Notify", s, startticks) else { flerror = true; adrsubscriber^.lastError = tryerror; <<log2.add (rssCloudInfo.name, "Notify", "Error: " + tryerror, startticks) if defined (adrsubscription^) { //3/16/11 by DW adrsubscription^.ctErrors++; adrsubscription^.ctConsecutiveErrors++; adrsubscription^.whenLastError = clock.now ()}}; system.temp.rssCloud.ctNotifyThreads--; bundle { //log the event if flLog { local (urllist = string.urlsplit (server), feedlink); local (servername = string.nthfield (urllist [2], ":", 1)); //pop the port off the name of the server local (protocolname = urllist [1] - "://"); bundle { //set feedlink local (feedinfo); rssCloudSuite.getFeedInfo (feedurl, @feedinfo); if defined (feedinfo.title) { feedlink = "<a href=\"" + feedurl + "\">" + feedinfo.title + "</a>"} else { feedlink = "the <a href=\"" + feedurl + "\">feed</a>"}}; local (s = "Subscriber <a href=\"" + server + "\">" + servername + "</a> was notified that " + feedlink + " has changed via <i>" + protocolname + "</i> protocol."); if flerror { s = s + "<br /><br />Error: " + adrsubscriber^.lastError}; log2.add (rssCloudInfo.name, "Notify", s, startticks)}}; return (not flerror)}; bundle { //test code notifyOne (@config.rssCloud.subscriptions.["http://www.scripting.com/rss.xml"].["xmlrpc://75.37.83.20:5337/RPC2"])}
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.