Monday, November 08, 2010 at 12:00 AM.
scripting2Suite.data.code.realtime.client.getUpdates
on getRealtimeUpdates () { <<Changes <<7/15/10; 10:09:17 AM by DW <<Cribbed from instantOutline.root. <<2/3/09; 10:56:03 AM by DW <<Use the parameterized roomname, not the fixed one. <<1/1/09; 7:08:38 PM by DW <<Massive change -- we no longer poll. Instead we use FriendFeed's realtime updates capability. Much more responsive, and less of a resource hog. Total win-win. <<7/21/08; 5:58:03 AM by DW <<Add stats for tracking how long calls to FF take. <<7/19/08; 2:48:41 PM by DW <<Don't process updates from "davewiner" and "bullmancuso" -- these are just temporary limits, until we safe-up everything for users who don't exist anymore (they became dave and bull). <<7/19/08; 1:37:15 PM by DW <<When processing updates, just set the dirty bits on the users, read the outlines after the loop. This way if someone updates twice we only read once. <<7/16/08; 8:07:40 PM by DW <<Created. local (adrdata = realtime.init (), fldebug = true, adrdebugtable, username, password, server); system.temp.realtime.stats.idRealtimeThread = thread.getcurrentid (); adrdata^.client.stats.whenRealtimeThreadStart = clock.now (); adrdata^.client.stats.ctRealtimeThreadStarts++; username = adrdata^.client.prefs.username; password = string (adrdata^.client.prefs.password); server = string (adrdata^.client.prefs.server); bundle { //set up debug table if fldebug { adrdebugtable = @system.temp.realtime.client.updates; //primarily for debugging if not defined (adrdebugtable^) { new (tabletype, adrdebugtable)}}}; loop { try { local (updates = [server].realtime.getupdates (username, password), adrupdate); for adrupdate in @updates { bundle { //call the callbacks local (adrscript); for adrscript in @adrdata^.client.callbacks.handleUpdate { if typeof (adrscript^) == addresstype { adrscript = adrscript^}; try {adrscript^ (adrupdate)}; adrdata^.client.stats.ctUpdates++}}; if fldebug { adrdebugtable^.[nameof (adrupdate^)] = adrupdate^}}; adrdata^.client.stats.ctRealtimeLoops++; adrdata^.client.stats.whenLastRealtimeLoop = clock.now ()} else { if not (string.lower (tryerror) contains "timed out") { adrdata^.client.stats.lastError = tryerror; adrdata^.client.stats.ctErrors++}}}}; bundle { //test code getRealtimeUpdates ()}
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.