Saturday, April 02, 2011 at 9:20 PM.

rssCloudSuite.notifySubscribers

on notifySubscribers (feedurl) {
	<<Changes
		<<7/19/09; 9:14:20 AM by DW
			<<Factored the core code into rssCloudSuite.notifyOne, so I can do each notification in its own thread, so they can happen simulataneously, not serially.
		<<7/12/09; 6:06:02 PM by DW
			<<Created. 
	local (adrdata = rssCloudSuite.init ());
	adrdata^.stats.ctNotifySubscribers++;
	adrdata^.stats.whenLastNotifySubscribers = clock.now ();
	adrdata^.stats.urlLastNotify = feedurl;
	local (adrsubscriptions = @adrdata^.subscriptions.[feedurl]);
	if defined (adrsubscriptions^) {
		local (adrsubscription);
		for adrsubscription in adrsubscriptions {
			while system.temp.rssCloud.ctNotifyThreads > adrdata^.prefs.maxConcurrentThreads {
				clock.waitseconds (1)};
			thread.callscript (@rssCloudSuite.notifyOne, {adrsubscription})}; //rssCloudSuite.notifyOne (adrsubscription)
			<<bundle //old code
				<<local (server = nameof (adrsubscription^))
				<<rssCloudSuite.initSubscription (adrsubscription)
				<<local (adrsubscriber = @adrdata^.subscribers.[server])
				<<local (startticks = clock.ticks ())
				<<try
					<<if server beginswith "http://" //special case for http-post
						<<local (params)
						<<new (tabletype, @params)
						<<params.url = feedurl
						<<tcp.httppost (server, @params)
					<<else
						<<[server].[adrsubscriber^.notifyProcedure] (feedurl)
					<<adrsubscription^.whenLastUpdate = clock.now ()
					<<adrsubscription^.ctUpdates++
					<<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
					<<adrsubscriber^.lastError = tryerror
					<<log2.add (rssCloudInfo.name, "Notify", "Error: " + tryerror, startticks)
		return (true)}};
bundle { //test code
	local (adrdata = rssCloudSuite.init ());
	notifySubscribers (adrdata^.stats.urlLastNotify)}



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.