Monday, November 08, 2010 at 12:00 AM.
scripting2Suite.data.code.realtime.server.pushUpdate
on pushUpdate (htmltext, type="", userWhoCausedUpdate="", data=nil) { <<Changes <<7/19/10; 10:06:44 AM by DW <<Cribbed from scripting2.root. <<7/16/10; 7:43:21 AM by DW <<Add another level under each users' realtimeUpdates table, with the IP they're connecting through. <<7/15/10; 8:08:43 AM by DW <<Add three optional params, type and userWhoCausedUpdate and data. Type of course can distinguish between classes of updates. I added this so the instant outliner could push its updates out through this channel. userWhoCausedUpdate indicates which user caused the update. <<data is any data that should be attached to the update. It's up to the type to determine what data it might want to send. <<7/13/10; 7:56:37 AM by DW <<Created. local (adrdata = realtime.init (), adruser, now = clock.now (), t); local (serialnumstring = string.padwithzeros (adrdata^.server.stats.ctMessages++, 7)); local (sem = realtime.server.data.semaphoreName); bundle { //set up table for update new (tabletype, @t); t.htmltext = htmltext; t.type = type; t.username = userWhoCausedUpdate; if data != nil { t.data = data}; t.when = now}; for adruser in @adrdata^.server.users { if adruser^.prefs.enabled { local (adrinbox); for adrinbox in @adruser^.inboxes { semaphore.lock (sem, 180); adrinbox^.queue.[serialnumstring] = t; semaphore.unlock (sem); adrinbox^.stats.ctPushes++; adrinbox^.stats.whenLastPush = now}}}}; bundle { //test code pushUpdate ("Hello from Hollywood")}
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.