Monday, November 08, 2010 at 12:00 AM.


on client () {
		<<12/27/09; 9:38:47 AM by DW
			<<Ooops. Failed to set flfirstloop false, so every call was a POST. Glad we caught that one! :-)
		<<12/26/09; 5:45:42 PM by DW
			<<In the first call, send the OPML subscription list in the body with the method == POST.
		<<12/15/09; 9:47:58 AM by DW
	local (flfirstloop = true);
	loop {
		local (adrdata = river2suite.init (), xstruct);
		if not adrdata^.prefs.cloudPipeClient.enabled {
		try {
			bundle { //call the server, xstruct contains what it returned
				local (urllist = string.urlsplit (adrdata^.prefs.cloudPipeClient.apiUrl), method = "GET", body = " ");
				if flfirstloop or adrdata^.stats.cloudPipeClient.flFeedsDirty {
					method = "POST";
					body = river2Suite.opmlBuild ();
					flfirstloop = false;
					adrdata^.stats.cloudPipeClient.flFeedsDirty = false};
				local (s = string.httpResultSplit (tcp.httpClient (method, server:urllist [2], path:urllist [3], username: adrdata^.prefs.cloudPipeClient.username, password: adrdata^.prefs.cloudPipeClient.password, timeoutticks:60 * adrdata^.prefs.cloudPipeClient.ctSecsTimeout, flmessages:false, data:body)));
				<<scratchpad.cloudpipestring = s
				bundle { //call the callbacks
					local (adrscript);
					for adrscript in @river2Suite.cloudPipe.callbacks.clientXml {
						while typeof (adrscript^) == addresstype {
							adrscript = adrscript^};
						try {adrscript^ (s)}}};
				xml.compile (s, @xstruct)};
				<<scratchpad.cloudpipestruct = xstruct
			bundle { //do callbacks for each packet in the returned struct
				local (adrpackets = xml.getaddress (@xstruct, "packets"), adrpacket);
				for adrpacket in adrpackets {
					local (name = string.nthfield (nameof (adrpacket^), "\t", 2));
					local (adrcallback = @river2suite.cloudPipe.callbacks.client.[name]);
					while typeof (adrcallback^) == addresstype {
						adrcallback = adrcallback^};
					try {
						adrcallback^ (adrpacket)}}}};
bundle { //test code
	client ()}

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.